Jquery - Trying to figure out how to find a certain class then name -- and then do something with them
I'm trying to figure out h开发者_开发百科ow to find a certain class name within a div AS WELL as a certain name, in the same div. I'm having trouble finding anything besides parent/child, or maybe I'm off-base. What I'd like to do is pick out each of these and then add up how many there are with this, total. Thanks.
Try this:
var items = $(".<CLASS-NAME>[name='<ELEMENT-NAME>']", "#idOfDiv");
alert(items.length);
e.g:
var items = $(".someclass[name='somename']", "#interestedDiv"); //If the div should be identified by different selectors replace #interesedDiv with other selector.
alert(items.length);
精彩评论