Reputation: 24103
What is better?
var itemId=8;
$('#aaa').data('ItemId', itemId);
$('#aaa').attr('ItemId', itemId);
data or attr?
Upvotes: 1
Views: 431
Reputation: 817208
They serve different purposes.
.data()
. .attr()
.Don't "invent" new attributes (appart from HTML5 data attributes). But as you are using jQuery, stick with .data()
.
Upvotes: 6