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&nbsp;<input type="text" id="disabledinput1" name="disabledinput1" /></label>             <br />             <label>disabled input 2&nbsp;<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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -