Reputation: 19
Using jQuery how could I obtain the link inside this a
tag?
<a title="Rainham Pizza and Kebab" href="/rainham-pizza" class="restsRestStatus restPageLink restsStatusOpens"><b>Pre-order</b><span>Opens 16:00 </span></a>
I have tried using:
jQuery("a.restsRestStatusrestPageLinkrestsStatusOpens").html();
Upvotes: 0
Views: 141
Reputation: 7073
use prop() over attr() in the majority of cases.
prop() is the current state of the input element, attr() is the default value.
prop() can contain things of different types, attr() can only contain strings
var url = $('a.restsRestStatus ').prop('href');
Upvotes: 0
Reputation: 25527
You can use .attr()
in jquery
("a.restsRestStatus.restPageLink.restsStatusOpens").attr("href")
Upvotes: 1
Reputation: 1447
$("a.restsRestStatus.restPageLink.restsStatusOpens").attr("href");
Upvotes: 2
Reputation: 18873
Try using .attr() as shown :-
var url = $('a.restsRestStatus').attr('href');
alert(url);
OR
var url = $("a.restsRestStatus.restPageLink.restsStatusOpens").attr("href");
alert(url);
Upvotes: 1