I’m looking to change the links in two containers I have from link.php to ../link.php on certain pages.
Can someone help my with the jQuery code I need to do this?
The containers are two divs, one with the id=”nav” and one with the id=”fnav”
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume by links, you mean the
aelements. You can use the multiple selector, to get a reference to your divs, search for allaelements usingfindand change thehrefwithattr:You can pass a function to
attrwhich gets the old value as parameter. So this prepending all paths with"../".If you only want to change the links that refer to
index.php, then use the attribute selector:.find('a[href="index.php"]')