attribute « attribute « jQuery Q&A

Home
jQuery Q&A
1.addClass
2.alert
3.array
4.attribute
5.browser
6.callback
7.clone
8.Cookie
9.Date
10.Development
11.document
12.dom
13.element
14.filter
15.Firefox
16.flash
17.format
18.html
19.input
20.internet explorer
21.json
22.mootools
23.page
24.performance
25.regex
26.safari
27.selector
28.setTimeout
29.String
30.table
31.Text
32.trigger
33.URL
34.video
35.xml
jQuery Q&A » attribute » attribute 

1. JQuery attributes    stackoverflow.com

the following is my HTML DOM element...

<input type="text" style="width: 200px;" id="input1"/>
I want to keep the date value in it..But somewhere i need to specify that it is going to hold date ...

2. Check existence of an attribute with JQuery    stackoverflow.com

I have a colection of checkboxes with generated ids and for a reason, some have an extra attribute. Is possible using JQuery to check if an element has a specific attribut ...

3. jQuery attribute question    stackoverflow.com

I'm trying to select a series of divs one at a time. I'm sure theres a better way to do this, but I gave them all unique rels and I'm ...

4. How to include two attributes with jQuery    stackoverflow.com

I am new to javascript in general and pretty much have no idea what is going on. Sorry for the super noobie question. I have an accordion being started with the following ...

5. Unobtrusive JavaScript - Safe Attributes?    stackoverflow.com

I'm working on separating JavaScript code from my HTML. I currently have code that looks like this:

<div onclick="return do_something_with('100566');" class="clickable">Click Me!</div>
I'd like to swap the onclick to an attribute containing just ...

6. Is HTML 5 supported by all the main browsers?    stackoverflow.com

I am looking at the custom attributes feature of html 5 here at this link http://ejohn.org/blog/html-5-data-attributes/ This look like the perfect thing for when I am using jquery/javascript. ...

7. jquery - how to set parent attribute?    stackoverflow.com

I'm trying to write an if statement where if one of the elements has it's display set to "none", I want the parent element to also display "none"... This is ...

8. Get all attributes    stackoverflow.com

is there a way to get the list of attributes set to an element? example: <div id="myID" title="I am Title" myAttr="I am something else">Hello World!!!</div> is there a way to get all the ...

9. Attributes in JQuery    stackoverflow.com

Suppose I have these divs:

<div class="hat" rel="cap">
<div class="hat" rel="pine">
<div class="hat" rel="mouse">
How do I use JQuery to do a "where"? For example
$("div.hat").remove WHERE rel="mouse"

10. Jquery: Conditional reference to attribute?    stackoverflow.com

Is it possible to refer to an attribute of an element conditionally with Jquery? What I'm after is something like:

$(".mylink":rel["2"]).show();
... which would "show the specific instance of .mylink element on the page ...

11. jQuery get attribute    stackoverflow.com

I'm trying to get the source attribute of all images withing a specific div but somehow it keeps telling me that the function .attr() doesn't exist... That's the function. Firebug also tells ...

12. Setting an attribute in Jquery not working    stackoverflow.com

I have the following function which limits the amount of characters you can enter into a text area. What's meant to happen is, if the text length is higher than the text ...

13. jQuery size() method vs length attribute    stackoverflow.com

Is there any difference between $(".selector").size() and $(".selector").length ?

14. How to get attributes of container in jquery?    stackoverflow.com

How can I get attributes values from an container using jquery ? For example: I have container div as:

<div id = "zone-2fPromotion-2f" class = "promotion">
here how can I get attribute id value using ...

15. jquery get attributes    stackoverflow.com

I'm looking for a way to grab the custom attributes of a element with jquery.

<span id='element' data-type='foo' data-sort='bar'></span>
I'm looking to get: ["data-type", "data-sort"] as an array. Anyone know how to do this? Thanks. ...

16. jQuery get attribute    stackoverflow.com

There are many class="item" blocks on the page. For each one there is different var item_link and ajax request. Ajax searches for src attribute of .message img and throws it to var src.

$(".item").each(function(){
 ...

17. Get the file Attributes (client side) using Javascript    stackoverflow.com

In my application, I need to calculate the size of the file in client side (before uploading to server). I want to restrict the file being uploaded if it doesn't ...

18. Make Parent Attribute    stackoverflow.com

can someone help me with jquery. i have a html TAG like this <p class="celak">hohohohoho</p> and i want to make the output (give its parent) be like this <div class="celak-parent"><p class="celak">hohohohoho</p></div> is there somebody know ...

19. Using html() as an attribute with jQuery    stackoverflow.com

I am trying to select an element in the list depending on its html content. I was hoping to do something like $('li[html="something"]'), but of course html isn't an attribute. Is ...

20. jQuery check if attribute contain substring    stackoverflow.com

Here's my problem: Consider the following html:

<div id="item1" class="green_large">
<div id="item2" class="green_large">
<div id="item2" class="green_small">
<div id="item4" class="yellow_large">
<div id="item5" class="yellow_large">
How do I check if $(this) contain a class name with the substring "yellow" for ...

21. jQuery: How to test is the browser supports the native placeholder attribute?    stackoverflow.com

I'm trying to write a simple placeholder jQuery plugin for a site of mine but of course I only want to fire the function if the native placeholder attribute isn't supported… How ...

22. Is there any problem with using HTML5's "data-*" attributes for older browsers?    stackoverflow.com

I want to associate some custom data with some HTML nodes. I was going to use the new HTML5 style 'data-*' attributes. e.g.: <tr class="foo" data-typeid="7">…, and then I was going ...

23. Using java servlets and page attributes with jQuery and javascript    stackoverflow.com

Currently I am using java servlets to set up Hashmaps, lists, and range of business objects and then pass them to a jsp page via request.setAttribute("myMap", myMap); How can I directly access ...

24. Attributes do not set up    stackoverflow.com

Why does this not work? (http://jsfiddle.net/J8n2g/):

$('body')
  .append($('<img>')
  .attr({
    'src': 'http://www.google.com/intl/en_ALL/images/logo.gif', 
    'width': '100%', 'height': '100%' })
  .hide()
  .load(function() { $(this).show(); ...

25. What's The Correct Way To Set Src Attribute In JQuery?    stackoverflow.com

Suppose I have the following HTML:

<img id="foo" src="bar1.jpg"/>
I would like to switch the src to bar2.jpg Can I just do this?
$("#foo").attr("src", "bar2.jpg");
Or do I have to do this?
$("#foo").removeAttr("src");
$("#foo").attr("src", "bar2.jpg");
Thanks!

26. refreshing javascript by renaming src attribute    stackoverflow.com

I want to refresh the output of the script below. Is this json? Do I need to add a crossdomain policy in my site?

<div id="nowplaying">
   <script src="http://s4.total-streaming.com/xml.php?station=1269&get=js"></script>
</div>

Edit:
This is ...

27. Very simple jQuery attribute question    stackoverflow.com

Either I have misunderstood the jQuery docs for .attr(), or I'm making a very stupid error. Why isn't this working?

<div id="mydiv" title="mytitle"></div>
<script type="text/javascript">
$(document).ready(function(){ 
    var username ...

28. Attributes for passing data in HTML    stackoverflow.com

I am using jQuery and in order to perform dynamic computations I need to store some information along an anchor tag, such as:

<a href="blah.html" username="some value" age="12" address="blah">click</a>
Of course this code ...

29. HTML file attribute issue     stackoverflow.com

<input type="file" id="file-id" />
<input type="text" name="file_path" id="file-path">
in jquery:
$("#file-path").val($("#file-id").val());
gives me : - 'C:\\fakepath\\test.py'
I am using ubuntu as my operating system. If I selected a file from /home/mylappy/Document/test.py It shows me the file ...

30. Getting HTML with the data using jQuery    stackoverflow.com

I have a form which has many elements (e.g. textarea, input, select), after users have entered some data the states of these elements should change. For example, an input[type="radio"] element will have ...

31. Cannot use 'javascript' because another language has been specified earlier in this page (or was implied from a CodeFile attribute)    stackoverflow.com

I have a website in which I am including a javascript file from this link: Code Snippet Page I am getting this error: Microsoft JScript runtime error: Object expected Here is my ...

32. Why won't this jQuery one-liner do what it is supposed to?    stackoverflow.com

I'm working on some form UI coding and wrote this jQuery one-liner:

$('input[type=text]').val($(this).attr('default-value'));
Intention is to give every input text field its default value which is supplied within an attribute. Any suggestions? TIA ...

33. How to check if 'this' has a specific attribute?    stackoverflow.com

I want to check if the element I click (this) has a specific attribute, as a condition in the if clause. Is it possible to do this with JavaScript or jQuery? Thanks

34. How do I get custom HTML attribute in jquery each() loop    stackoverflow.com

I have the following HTML

 <input type="text" name="first" expression="firstExpression"/>
 <input type="text" name="last" expression="secondExpression"/>
 <input type="text" name="age" expression="thirdExpression"/>
I have a custom expression attribute. I using jQuery to iterate over all the input ...

35. jQuery code removeAttr issue    stackoverflow.com

<input id="mnc" type="text"/>
<input type="text" id="selected" />

$('#mnc').val().length ? $('#selected').attr({
    'size': $('#mnc').val()
}) : $('#selected').removeAttr('size');
This gives an error in Firefox 4.
Index or size is negative or greater ...

36. getting attribute from DOM using jQuery    stackoverflow.com

I am using this jQuery star rating plugin and I would like to get the name of the star that I clicked. The code can be fiddled

37. jquery attribute getter breaks my webkitdotnet    stackoverflow.com

I use a webkit dot net browser through c#, and I have a website that I am showing through that browser in a desktop application. Anyway, I came to ...

38. jquery choosing methods    stackoverflow.com

I love using the hide() and show() methods, but I've come across someone's scripting where they never use it.
Instead I see them using attr() for anything related to display.

$("#element").attr("style", "visibility:hidden");
$("#element").attr("style", ...

39. jQuery html Attributes issue    stackoverflow.com

I use the jQuery html Attributes to wrap some words in a large piece of text, this works fine but if the text has some html tags in it, it will ...

40. Setting jQuery attribute for font-weight    stackoverflow.com

I am trying to change the font-weight of an element. I tried with the following but it doesn't seem to work:

$("#opt_" + i).attr("font-weight", "bold");
Also what's the difference between prop and attr? ...

41. Why are jQuery set attributes not reflected in .html()?    stackoverflow.com

I am trying to set some attributes on HTML snippets. The purpose is to repopulate a form with previous inputed values. I set attributes with .attr() but after I do a ...

42. is it possible to create custom Identification attributes?    stackoverflow.com

is it possible to create a identification attribute sort of a class or an id and assign it in jQuery selector with special character? for example I want an "identity" attribute to ...

43. Unable to set data attribute using jQuery Data() API    stackoverflow.com

I've got the following field on an MVC view:

@Html.TextBoxFor(model => model.Course.Title, new { data_helptext = "Old Text" })</span>
In a seperate js file, I want to set the data-helptext attribute to a ...

44. javascript problem setting attribute    stackoverflow.com

I'm trying to set the attribute of an element programmatically, but firebug keeps giving the error: obj.setAttribute is not a function. I'm using jQuery so I'm going to show a bit ...

45. jQuery and data-attributes to handle all ajax calls?    stackoverflow.com

I'm thinking of a way to reduce the amount of javascript code by enabling ajax on links from attributes. Example:

<a href="/Default/Link.html" data-endpoint="/Ajax/Link.html" rel="targetId" async="true">Click me!</a>
async="true" will disable default behaviour of the ...

46. How to send a session scoped attribute through jquery ajax call    stackoverflow.com

I have an issue I have this jQuery code:

    $(document).ready(function(){
        $("#follow").click(function(){
           ...

47. Potential Bug with jQuery data() when dynamically chaning attribute?    stackoverflow.com

I have no idea if I just found a potential jQuery bug, but check out the following case. If I'm dynamically changing a data-ajax-link attribute and then try to get it's value ...

48. jQuery endsWith for attributes    stackoverflow.com

using jQuery, I'm trying to see if a random id ends with a certain string using the following pseudo code:

var node = $('#foobar');

if (node.attr('id').endsWith('bar')) {
 // do stuff
}
I know for node ...

49. Getting the attribute of a parent    stackoverflow.com

I'm trying to get the id of a table using a table row. While I am in a loop:

$(this).parent.attr('id');
However I am getting an error. Is my syntax right? Thanks. EDIT:
<table id="21-rawTable" border="1"><tbody><tr class="even ...

50. Creating a data-track Attribute that jQuery binds to for tracking data    stackoverflow.com

Here's what I'm thinking about doing. using a data-track attribute in links and buttons that would contain data I want to send to Mixpanel... Something like: click it Then somehow jQuery bind to ...

51. Set Highslide attribute with jQuery    stackoverflow.com

This is working when using images:

$("#div).attr('onClick', 'return hs.expand(this)');
This is not when using ajaxed content:
$("#div").attr('onClick', 'return hs.htmlExpand(this, { objectType: 'ajax'} )');
Probably there is something wrong with the syntax.

52. Problem with Jquery    stackoverflow.com

I am dynamically creating HTML items using jQuery. Though items are dynamically created but their attributes are note. I mean if I assign class and id in the $() call, the ...

53. Custom HTML attributes and jQuery    stackoverflow.com

I am often needing to store little pieces of reference in a page element, most of the time a <div>. I couldn't find too much documentation on how valid it would ...

54. Using data attributes with jQuery    stackoverflow.com

I have this button:

<button type="button" class="themeChanger" data-themeValue="grid" value="Grid">
   <img src="templateImages/Icon_200.png" />                
</button>
And this jQuery:
$(".themeChanger").click(function ...

55. whole link created using attribute passing, not working.    stackoverflow.com

Trying to create a link dynamically for some purpose

$('', {
   text: 'Click here!',
   href: 'http://www.example.com',
   title: 'Click to win'
   }).appendTo('body');
But this is not ...

56. JQuery : Is it bad practice to use a custom attribute in my html code?    stackoverflow.com

I've been adding custom attributes which I reference using JQuery, this works great. But is it good practice? example:

<div class="monkeys" customattr="big Monkey"> </div>
thanks all

57. Are HTML attributes good for storing data?    stackoverflow.com

(Please disregard any security concerns you may have with this approach, I have a already taken more than enough precautions to make sure that there are no blatant vulnerabilities with this ...

58. data attribute removes leading zeros    stackoverflow.com

i have this html.

<img src="2.png" alt="Pending" data-number="00991" data-status="0">
i am using the following jQuery to fetch the value.
var number = $(this).find('img').data('number');
above jQuery code fetches values with non-leading zeros, for example the above ...

59. jQuery Accessing Widget Attributes    stackoverflow.com

Is it possible, to access a widget's attributes in jQuery, like in Dojo?

dijit.byId('#controlDiv').attr('text');

60. Is using custom attributes valid?    stackoverflow.com

I want to cancel any links and add extra attributes to each one. Below is how I've achieved this.

function anularEnlaces(){
    $('nav a').each(function(){
       ...

61. What's wrong with this html5 data attribute    stackoverflow.com

This is the anchor that MVC 2 is creating:

<a class="syncLink" data-resultstarget="OmsToAdminPzInfoSyncResult" 
     href="/Sync/OmsToAdminPzInfoAjax" 
     onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: &#39;OmsToAdminPzInfoSyncResult&#39; });">
Pz ...

63. Disabled is an attribute right?    forum.jquery.com

64. wrap-like method aimed at attributes?    forum.jquery.com

This is probably wishful thinking, but I'm wondering if there is an elegant way to take an array of strings and "wrap" each of them into becoming the value of a particular attribute in an html tag? The particular option is form-building; I have a bunch of options a,b,c and need to build , value=b, value=c, etc. ...

65. Can't use attribute called "controls"    forum.jquery.com

66. Problem setting an attribute...    forum.jquery.com

Not sure if the problem is you trying to set the id to an invalid string (an id must start with a lowercase letter). I'm sure you have declared the variable "l" so you know what it is from start. The string you have as a parameter in the clone method doesn't do anything.

67. 1.6.1 html5 data attributes - 'data-someValue' doesn't work    forum.jquery.com

I understood the jQuery documentation for 1.6.1 to say that the data-camel-casing will be converted to data('camelCasing'). Given this, is seemed logical going forward that it would be better to use this nomenclature for our attribute names, so I created a test page and changed one of our attribute names from "data-rec-ed" to "data-recEd".

69. [SOLVED] .live() attributes    forum.jquery.com

I am having an issue with retrieving the attribute of an element that I have ajax'ed into my site, the following is the code that brings it in: $('a[rel=newpoint]').live('click', function() { jQuery.facebox(function(){ ...

70. [Warning newb] Working with attributes    forum.jquery.com

71. Cannot set checked attribute    forum.jquery.com

72. Check attribute is present    forum.jquery.com

73. Reverse attribute checked    forum.jquery.com

I have a number of inputs (chk_0, chk_1 ,....) residing each in their own div. When an input is clicked I need to reverse the "checked" value for that particular checkbox input . However I cannot find the right syntax to do that : Creating the inputs $('#mydiv' + i).addClass('labelForStyler') // add class for divs ...

74. How to set attribute when loaded ?    forum.jquery.com

75. custom attributes    forum.jquery.com

I want to be able to assign a tooltip to these elements that will pass the amount value (10) to an ajax to calculate the taxes for the logged in user and display it in the tooltip. I have this working fantastically, but again - the amount attribute is no valid html if we want to validate strictly.

77. [jQuery] Can't get attributes from ajax response...    forum.jquery.com

Hi ,I'm making a ajax call using $.ajaxmy code is$.ajax({ type: "POST", url: "sample.php", dataType:"html", data: "name="+$('#name').val(), success: function(msg){ $('#result').append(msg); } });And the response isUser1When i try to get the Id from the response, it's seems not working..$('.user-link').click(function(){alert($(this).attr('id'));});And i need to make this work urgently...Any help will be greatly appreciated...Thanks in advance...

78. Jquery attribute purpose? Blocking referrer!    forum.jquery.com

I was wondering what jQuery uses these attributes for inserted into the anchor tags (i.e. jQuery1250190927174="40")? I am able to modify the code using IE Developer Tools. On the links, I get a referrer if I remove the jQuery attribute (which is inserted dynamically) from the anchor tags. Example below: So what's the purpose of this ...

79. [jQuery] Custom Attributes - Beginner tip    forum.jquery.com

One issue I ran across while learning jquery was that I often wanted/needed a way to tell jquery to get data for the current element from arelated element. jQuery immediately tends to be friendly when you needto work with a class of elements via the CLASS attribute, or aspecific element via the ID attribute. However, when there are 2elements that are ...

80. [jQuery] Requirement for duplicate AJAX attribute name    forum.jquery.com

All,I have a situation where I need to pass the same named attribute to anAJAX enabled endpoint. Basically I need to simulate something likehttp://example/cgi?text=1500characters&text=1500characters. I needthis type of scenario to work in typical JQuery AJAX and JSONP calls.I understand that I may run into browser/server URL limitations.In case anyone is wondering, Im AJAX enabling some old PL/SQL codeusing Oracle's Webtoolkit and ...

81. [jQuery] Creating custom attributes in html    forum.jquery.com

I was wondering what jquery developers opinion of adding customattributes to html tags is, and what your basis is for theseopinions? Why is it a good idea, or why is it a bad idea? What Imean is this:

content
where 'myType' isn't in any specifications. I've run into developerswho think this is a good idea, and those who think this is ...

82. [jQuery] getting data using html attribute    forum.jquery.com

[jQuery] getting data using html attribute in Using jQuery 2 years ago Hi,i have several html tags with some additional attributes like 'type' or 'abbr'. for example :<thid="col_1"class="ColumnHeader"align="center"abbr="language"

84. [jQuery] Jquery how to get attribute from a HttpServletRequest    forum.jquery.com

Hallo all: I got this piece of code:$("#faq").click(function () { var url = $.get("faq", { pagina: "page" }); alert(url);});On "faq" responds a Servlet tha set an attribute on the request ....request.setAttribute("pageFAQ", pageFAQ); ....After the get jqeury print me [object XmlHttpRequest I would like toaccess to the attribute setted in the Servlet but I dunno how to do.Any idea?Kind regardsMassimo UGues

85. JQuery cannot get displaytag attributes?    forum.jquery.com

87. control attribute for HTML5    forum.jquery.com

The aim of the metadata plugin is accessing data form HTML5 data attributes. My suggestion is to use data-control attribute as a standard way to add jquery controls to html tags, and make it as a standard part of jquery core. It is something like Dojo's dojotype, or Entourage's (http://doc.appcelerator.org/ui:start) control attribute. It is only a small thing (yes, you can ...

89. Can't get attributes from ajax response...    forum.jquery.com

Hi ,I'm making a ajax call using $.ajaxmy code is$.ajax({ type: "POST", url: "sample.php", dataType:"html", data: "name="+$('#name').val(), success: function(msg){ $('#result').append(msg); } });And the response isUser1When i try to get the Id from the response, it's seems not working..$('.user-link').click(function(){alert($(this).attr('id'));});And i need to make this work urgently...Any help will be greatly appreciated...Thanks in advance...

90. Proposal on Attributes - replaceClass    forum.jquery.com

Wouldn't it be better to toggle between the first and the second class, rather than limiting it to replacing the first with the second?

$.fn.swapClass = function(c1, c2) {
return this.each(function() {
var $this = $(this);
if ( $this.hasClass(c1) )
$this.removeClass(c1).addClass(c2);
else if ( ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.