Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10668 closed enhancement (invalid)

Allow jQuery.data() to update data-attributes

Reported by: rodneyrehm Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7
Keywords: Cc:
Blocked by: Blocking:


jQuery.data() should be able to (selectively) update data-attributes in order to make something like

$('.selector').data('foobar', 1);

selectable like


see modified code and jsFiddle for a possible solution (introducing a new argument 'updateAttr').

Change History (2)

comment:1 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

Nope. By design we don't write to those attributes under any circumstances, and doing so in a consistent way would affect all the data APIs plus incur a big performance penalty. Use .attr().


comment:2 Changed 11 years ago by rodneyrehm

I'm terribly sorry to have bothered anyone with this. There's a much simpler (and imho cleaner) solution to this: http://jsfiddle.net/rodneyrehm/XV33m/

Note: See TracTickets for help on using tickets.