So I have this html markup:
<div class="buttons-holder>
<label class="my-btn">
<input name="example" value="1" type="radio"> YES
</label>
<label class="my-btn">
<input name="example" value="0" checked="checked" type="radio"> NO
</label>
</div>
But sometimes I have more than one label inside the .buttons-holder
element. How can I specify in jQuery to apply my jQuery code only if there exists 2 label elements?
I tried something like this but it still applies to all elements:
if ($('form label:has(input[type="radio"])').eq(2)) {
//do something
} else {
//do something else
}
Jsfiddle: http://jsfiddle.net/jw51hggc/