I managed to get help on another thread for changing the title and link of an element using JavaScript (Issue with changing the title of a link using jQuery).
I have tried implementing the technique there to another element on my website but am instead met with an error Error 404: The page your are looking for cannot be found.
Thus, while this code works in isolation:
var href = jQuery('#_tab_1 > div > div > div:nth-child(3) > div > div.pf-body > ul > li:nth-last-child(1) > p.item-property').html();
var link = "<a href='"+href+"' target='_blank'>Click Here</a>";
jQuery('#_tab_1 > div > div > div:nth-child(3) > div > div.pf-body > ul > li:nth-last-child(1) > p.item-property').replaceWith(link);
The following code leads to the error mentioned above.
var href = jQuery('#_tab_1 > div > div > div:nth-child(3) > div > div.pf-body > ul > li:nth-last-child(1) > p.item-property').html();
var link = "<a href='"+href+"' target='_blank'>Click Here</a>";
jQuery('#_tab_1 > div > div > div:nth-child(3) > div > div.pf-body > ul > li:nth-last-child(1) > p.item-property').replaceWith(link);
var href2 = jQuery('#c27-single-listing > section > div.profile-cover-content.reveal.reveal_visible > div > div > ul > li:nth-child(3) > div').html();
var link2 = "<a href='"+href2+"' target='_blank'>Click Here</a>";
jQuery('#c27-single-listing > section > div.profile-cover-content.reveal.reveal_visible > div > div > ul > li:nth-child(3) > div').replaceWith(link2);
Attached is the link to the html code I am targeting (Link). Note that the link only reflects the html related to the javascript code that I can't get working ie. href2
. I had not posted the segment that href was targeting as it might get too messy. My purpose is to replace www.hotmail.com
with the words Click Here
, but the user should be able to select Click Here
and it would direct them to www.hotmail.com
. Also, because I had to select only the relevant portions of the html, the selector you view in the link would be different from what is stated in my code above.
Thank you for your help.