What is better?
var itemId=8;
$('#aaa').data('ItemId', itemId);
$('#aaa').attr('ItemId', itemId);
data or attr?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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().