Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to change the href for a hyperlink using jQuery

How might you change the href for a hyperlink utilizing jQuery?
by

2 Answers

ninja01
With jQuery 1.6 and above you should use:

$("a").prop("href", "sample url")

The difference between prop and attr is that attr grabs the HTML attribute whereas prop grabs the DOM property.
ninja01
With jQuery 1.6 and above you should use:

$("a").prop("href", "sample url")

The difference between prop and attr is that attr grabs the HTML attribute whereas prop grabs the DOM property.

Login / Signup to Answer the Question.