When should I use one or the other?
The only difference I noticed is that with a click event
var $sth = $('.selector').data('sth');
seems to be cached, while
var $sth = $('.selector').attr('data-sth');
gets newly assigned every click.
What is the use-case for .data('sth');
?