html - Cannot change href attribute with jQuery -


i accessing links on webpage jquery, following code:

$('a[href]').each(function() {   $(this).attr('class', 'visited');   $(this).attr('href', '#'); }) 

the class on link changed, href not. there preventing me changing/altering href?

edit:

i updated code following:

$('a[href]').each(function() {         $(this).addclass('visited');         this.href = '#';         }) 

however, although works on websites, doesn't work on news.yahoo.com. reasons why so?

for href, want use .prop() instead of .attr().

for classname, in cases want use .addclass() instead of overwriting entire class attribute.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -