javascript - If parent element has only 2 child elements do something, else something else -


so have 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 have more 1 label inside .buttons-holder element. how can specify in jquery apply jquery code if there exists 2 label elements?

i tried still applies elements:

    if ($('form label:has(input[type="radio"])').eq(2)) {          //do      } else {         //do else     } 

jsfiddle: http://jsfiddle.net/jw51hggc/

based on comments , fiddle

$('form .buttons-holder').filter(function(){     return $(this).children('label:has(input[type="radio"])').length == 2 }).wrapinner('<div class="wrap"></div>'); 

demo: fiddle


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -