javascript - Replacing a href link using jQuery .attr -


i'm trying change content of href using jquery. i've found number of answers on site, , trying use 1 implement it:

how change href hyperlink using jquery

i have wrapped in if statement this:

if(window.location.href == "http://test.com/home.aspx"){      $("a[href='https://www.surveymonkey.com/s/tester123']").attr('href', 'https://www.surveymonkey.com/s/tester234'); } 

i've put console logs in place , show line of code being reached, , this:

$("a[href='https://www.surveymonkey.com/s/tester123']") 

is returning correct link. href value never replaced when check page source.

i'm using http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js?build=7111092

i'm bit stuck on how debug issue is, can spot it? stupid mistake!

--edit--

i have checked using inspect element , it's not been replaced unfortunately.

also @vohuman , @roxxypoxxy info on not being able see change unless hovered on it. stupidly expecting work find/replace!

i think jquery version issue. using jquery 1.5. in jquery docs have mentioned this

before jquery 1.6, .attr() method took property values account when retrieving attributes, cause inconsistent behavior.

source https://api.jquery.com/attr/

so try use higher jquery version or use .prop() instead of .attr()


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -