I\'m trying a very simple task working with data-attr and jQuery, check this example:
Markup:
Working demo http://jsfiddle.net/DDv8U/
$(div).data('name', ' - Testing 2');
rest should fit the need :)
code
$(function(){
var div = $('div');
$(div).append($(div).data('name'));
$(div).data('name', ' - Testing 2');
$(div).append($(div).data('name'));
});
You are changing the attribute but this doesn't automatically update the data. This works:
$(function(){
var div = $('div');
div.append(div.data('name'));
div.data('name', ' - Testing 2');
div.append(div.data('name'));
});