Friday, 9 August 2013

jquery - find an attribute value?

jquery - find an attribute value?

I have a series of containers containing map data and links. Im using
jquery to cycle through those containers to get certain data. In this
situation im trying to get an attribute of a link.
I use the following jquery to get all of the html of each container.
$(document).ready(function () {
$(".map_container").each(function () {
alert($(this).find(".map_content").html());
});
});
This creates an alert with a few lines of html, the line im concerned with
is below.
<a class="map_link" value="67" location="home"> Visit home </a>
How could I alert value of the location attribute. So in this case "home".
Something like
$(this).find(".map_content").attr("location");
or if possible just find the location without having to find the
map_content div first. so
$(this).find.attr("location");
or
$(this).find("a").attr("location");
what would be the correct way to get the location attribue of the map_link
link?
Thanks for any help

No comments:

Post a Comment