Linked Questions
16 questions linked to/from Unable to set data attribute using jQuery Data() API
-1
votes
1
answer
785
views
jquery data vs attr [duplicate]
I have this code (with jQuery 1.9.1):
var Clon = $('#mylabel');
then I would change data-attributes, but is not established when I check the value:
Clon.data('hello','1');
but this method return the ...
0
votes
2
answers
1k
views
Data attributes don't update when button is clicked a second time [duplicate]
I have some data attributes set to equal nothing when the page loads. Once a user selects an item from a list item it then populates the data attributes. I want to perform a simple validation that ...
4
votes
2
answers
646
views
jQuery .data() vs. .html() [duplicate]
strange problem - maybe I'm missing something.
My code:
HTML
<div id="container">
<span data-foo="initial content">Blabla</span>
</div>
jQuery
console.log($("span")....
1
vote
3
answers
79
views
Why can't I inline .data() like I can .attr() in Jquery dom node construction? [duplicate]
Given the below code I expect both foo and bar to have a div inside of them with the appropriate data attribute, but only the one using attr works. Am I missing something? Is this possible? Can ...
0
votes
0
answers
50
views
How to reset memory game with jQuery [duplicate]
My problem is that I want to make reset/new game button to my simple memory game and it went well until the cards have to shuffle again. Now it only works to play same game over and over again. Here ...
733
votes
4
answers
814k
views
jQuery selectors on custom data attributes using HTML5
I would like to know what selectors are available for these data attributes that come with HTML5.
Taking this piece of HTML as an example:
<ul data-group="Companies">
<li data-company="...
547
votes
3
answers
215k
views
jQuery Data vs Attr?
What is the difference in usage between $.data and $.attr when using data-someAttribute?
My understanding is that $.data is stored within jQuery's $.cache, not the DOM. Therefore, if I want to use $....
183
votes
9
answers
143k
views
jquery data selector
I need to select elements based on values stored in an element's .data() object. At a minimum, I'd like to select top-level data properties using selectors, perhaps like this:
$('a').data("category","...
33
votes
3
answers
11k
views
Why don't changes to jQuery $.fn.data() update the corresponding html 5 data-* attributes?
Here's a simple example to illustrate the behavior:
Given this html markup:
<div data-company="Microsoft"></div>
and this jQuery code (using jQuery 1.5.1):
// read the data
alert($("div"...
3
votes
1
answer
3k
views
jQuery data value not updating
Could someone explain why this isn't working?
What I'm trying to do is update a data attribute called 'section_id' in a dropped element with the new section it has been dropped into. I check this ...
3
votes
1
answer
4k
views
jQuery appendTo with some data = append element without data
I'm using jQuery, I have a simple list
<ul id="list">
<li data-kind="foo">Foo1</li>
<li data-kind="foo">Foo2</li>
<li data-kind="foo">Foo3</li>
</ul>...
0
votes
2
answers
1k
views
Data attribute value can't be updated
I want to update the value of data attribute. I checked showing alert message but when I inspect element the value is not updated. Here is my code:
alert(pid); // show 1
alert($('#buybtn')....
0
votes
2
answers
2k
views
Separating & cleaning up tags in data-attribute via jQuery
I have a list of items which will contain a tag using the data-type attribute. I'm attempting to loop through the items to grab each tag in an array. Where a list item has more than one tag (separated ...
2
votes
1
answer
980
views
set data- html5 value by default
I have this small code that put some preset style to a div with custom attributes, that attributes set the src and an APA text to an img tag, also generate a button with a zoom option using FancyBox......
0
votes
1
answer
388
views
Jquery on hover adding data id and with another on hover geting the data id but it is only getting the first id
In first hover i am getting data id from thumbs and adding to #main image it is working fine and with 2nd hover on #main i am getting the data id again here from the first data id. but it is only ...