I want to cancel any links and add additional attributes to each. Below is an example of how I achieved this.
function anularEnlaces(){ $('nav a').each(function(){ var href = $(this).attr('href'); var id = $(this).attr('id'); $(this).attr('href','javascript:void(0)'); $(this).attr('hrefnot',href); $(this).attr('nivel','uno'); $(this).attr('seccion','dos'); }); }
My question is, what is the valid / recommended way to add custom attributes?
source share