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=
If You want to get list only children elements with id or class, avoiding elements without id/class, You can use document. getElementById('container'). querySelectorAll('[id],[class]'); ... querySelectorAll('[id],[class]') will "grab" only elements with id and/or class.
$(".sort").click(function(){ var cat = $(this).children("span").attr("sortcat"); //do something with the sortcat });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With