javascript - traversing dom elements for right jquery selector -


given following html snippet, cant seem access input elements under div class="input-group"

 <form action="login.html#register" method="post" id="form-register" class="form-horizontal display-none">         <div class="form-group">             <div class="col-xs-6">                 <div class="input-group">                     <span class="input-group-addon"><i class="gi gi-user"></i></span>                     <input type="text" id="register-firstname" name="register-firstname" class="form-control input-lg" placeholder="firstname">                 </div>            </div>            <div class="col-xs-6">                <input type="text" id="register-lastname" name="register-lastname" class="form-control input-lg" placeholder="lastname">            </div>        </div>        <div class="form-group">            <div class="col-xs-12">                <div class="input-group">                    <span class="input-group-addon"><i class="gi gi-envelope"></i></span>                    <input type="text" id="register-email" name="register-email" class="form-control input-lg" placeholder="email">                </div>           </div>      </div> </form> 

i have tried numerous selector syntax nothing seems work. cannot figure out why version doesn't work, should, i'm no expert on jquery yet. me syntax below says items class form-group in element id form-register, divs class input-group , input tags in divs. mistaken there?

 $('#form-register.form-group > div.input-group > input').attr('disabled', true); 

the proper syntax is, via assistance accepted answer;

 $('#form-register div[class^="col-xs"] input').attr('disabled', true); 

your css syntax incorrect. try this:

$('#form-register .form-group div.input-group > input').attr('disabled', true); 

firstly, notice space between first 2 selectors, because .form-group child of #form-register. secondly > means 'direct child of', incorrect when used on div.input-group.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -