Link to home
Start Free TrialLog in
Avatar of netslt
netslt

asked on

replace link with jQuery

Hi

I try to replace a link on a page with the following jQuery code:

jQuery("a[href='https://www.blabla.com/category/roundtables/']").prop('href', 'https://www.blabla.com/roundtables/');

But it does not work - link stays the same.

What is wrong here?

Thanks!
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try:

$("a[href='https://www.blabla.com/category/roundtables/']").prop('href', 'https://www.blabla.com/roundtables/');

Open in new window

Avatar of netslt
netslt

ASKER

Thanks but this will not work because it is a Wordpress Page the code is running on.

Error (using $) is "Uncaught TypeError: $ is not a function"

So with WP you always have to use jQuery instead of $
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of netslt

ASKER

Ok that worked, seems like the script was called to early and that is why it did not work.