jquery - Loop through all inputs in a div with a certain class -
<script language="javascript" type="text/javascript" src="jquery-1.6.js"></script> <script> $('.disabledform').each(function(i, div) { alert('in here'); $(div).find('input').each(function(j, element){ $(element).attr('disabled','disabled'); }); }); </script> <div id="divdisabled" class="disabledform"> <label>disabled input 1 <input type="text" id="disabledinput1" name="disabledinput1" /></label> <br /> <label>disabled input 2 <input type="text" id="disabledinput2" name="disabledinput2" /></label> </div>
never see "in here" message , inputs never disabled assume i'm doing wrong. can tell me i'm not doing right?
you have wrap code in $(function(){ ... })
block, in order let see whole dom.
<script> $(function(){ //your js code here }); </script>
Comments
Post a Comment