If I have the following markup:
<p class="header hours">
<a href="javascript:void(0)" class="sort" sortcat="hours">
Hours <span class="imgholder" sortcat="hours"> </span>
</a>
</p>
How can I target the <span> tag within the anchor tag? There are five other similar <p> tag entries, each with a different value for sortcat=
$(".sort").click(function(){
var cat = $(this).children("span").attr("sortcat");
//do something with the sortcat
});
$("a span[sortcat]").attr('sortcat')
That'll give you the first element's sortcat value. To get all of them, do this:
$("a span[sortcat]").map(function(){ return $(this).attr('sortcat') })
See this working demo: http://jsfiddle.net/BwgDW/
$('.sort span')
Did I misunderstand?