What is better?
var itemId=8;
$('#aaa').data('ItemId', itemId);
$('#aaa').attr('ItemId', itemId);
data or attr?
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()
.