0

I can't classify these cases:

// first
$('#myDiv').attr('data-foo', 1);    

// second
$('#myDiv').data('foo', 1);

The first case appends data-foo to html tag which the id is myDiv and the second is not.

My question is: When to use the first and the second case?

p/s: I'm using jquery version 2.2.4

0 Answers0