Is there a way to change the href value for a link but leave its text the same?
<a id="mylink" href="www.link.com">click here</a>
I would like to simply change “www.link.com” and leave the text “click here” untouched.
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.
Use the
.attr()function to change an attribute on an element:Also, just an FYI (and this may even be why you’re changing it),
href="www.link.com"will result in a broken link, unless there’s actually a file calledwww.link.comin the same path as the page hosting the link. To go to another domain, the URL needs to be fully-qualified to include the protocol:href="http://www.link.com"