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

Eclipse formatter for java ending braces -

ruby - Nesting modules inside of a Rails eninge gem -

java - Are there any classes that implement javax.persistence.Parameter<T>? -