Reputation: 3465
I have some links with various hrefs and want to get definitive url for this value, like:
http://localhost/ -> http://localhost/
localhost -> http://mysite.example/localhost
firstpage -> http://mysite.example/firstpage
/anotherpage -> http://mysite.example/anotherpage
#anchor1 -> http://mysite.example/currentpage#anchor1
/#anchor2 -> http://mysite.example/#anchor2
BTW I don't want code for click handling. I can do that.
Upvotes: 2
Views: 382
Reputation: 1349
$("a:first").prop("href")
will give you the full URL of your first anchor tag as opposed to $("a:first").attr("href")
which will give you the text in the href attribute.
Upvotes: 5