How can I get <span> elements that have a specific class name in jQuery?
Using jQuery 1.9.1 and HTML5, I want to capture elements that have only specific class names.
Let's say I have the following HTML code:
<div> <span class="req">A</span> <span class="req notreq">B</span> <span class="req notreq">C</span> <span class="req">D</span> </div> I want to capture only <span> elements with class req , that is, the values ββof A and D.
Using jQuery, I can capture all the values ββusing console.log($('.req')); and all notreq values ββusing console.log($('span.req.notreq'))
I need only req values. Any help?
+4
3 answers