I want to cancel any links and add extra attributes to each one. Below is how I\'ve achieved this.
function anularEnlaces(){
$(\'nav a\').each(function()
No, you should use data() instead for custom element attributes, and attr() ( or better yet prop() ) for standard html attributes .
Example of data() usage :
test
// getter
var customValue = $('a').data('custom');
var customUndefined = $('a').data('testing');
Now customValue contains "value" string, and customUndefined contains undefined
// setter
$('a').data('custom', 'test');
$('a').data('testing', true);