javascript - Selecting Child fields of a div -
i have multiple div child fields. these child fields share similar names. trying show child fields of particular. getting child fields of first div.
does have child field's name
html
<div class="row childfields" id="parent-question1"> <p class="subtitle">give full details here: </p> <div class="col-md-6 colchildfields" style="display:none" name="condition"> <label class="poclabel">nature of condition</label> <input type="text" name="condition" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="datesandduration"> <label class="poclabel">dates , duration</label> <input type="text" name="datesandduration" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="doctorname"> <label class="poclabel">name of doctor</label> <input type="text" name="doctorname" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="hospitalname"> <label class="poclabel">name of hospital</label> <input type="text" name="hospitalname" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="hospitaladdress"> <label class="poclabel">address of hospital</label> <input type="text" name="hospitaladdress" class="form-control"> </div> </div> <div class="row childfields" id="parent-question2"> <p class="subtitle">give full details here: </p> <div class="col-md-6 colchildfields" style="display:none" name="condition"> <label class="poclabel">nature of condition</label> <input type="text" name="condition" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="datesandduration"> <label class="poclabel">dates , duration</label> <input type="text" name="datesandduration" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="doctorname"> <label class="poclabel">name of doctor</label> <input type="text" name="doctorname" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="hospitalname"> <label class="poclabel">name of hospital</label> <input type="text" name="hospitalname" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="hospitaladdress"> <label class="poclabel">address of hospital</label> <input type="text" name="hospitaladdress" class="form-control"> </div> </div> <div class="row childfields" id="parent-question3"> <p class="subtitle">give full details here: </p> <div class="col-md-6 colchildfields" style="display:none" name="condition"> <label class="poclabel">nature of condition</label> <input type="text" name="condition" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="datesandduration"> <label class="poclabel">dates , duration</label> <input type="text" name="datesandduration" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="doctorname"> <label class="poclabel">name of doctor</label> <input type="text" name="doctorname" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="hospitalname"> <label class="poclabel">name of hospital</label> <input type="text" name="hospitalname" class="form-control"> </div> <div class="col-md-6 colchildfields" style="display:none" name="hospitaladdress"> <label class="poclabel">address of hospital</label> <input type="text" name="hospitaladdress" class="form-control"> </div> </div>
jquery
var childfielddivid = '#parent-'+fieldname; $(childfielddivid).find('div').each(function(i, childfield){ $(childfield).show(); });
try this:
var childfielddivid = '#parent-'+fieldname; $(childfielddivid).find('div').each(function(index, value){ $(this).show(); });
Comments
Post a Comment