在jquery中的div内获取文本框id
我需要您的帮助,根据jquery中div的css类名查找div中的文本框id在jquery中的div内获取文本框id,jquery,Jquery,我需要您的帮助,根据jquery中div的css类名查找div中的文本框id <div class="FH_element FH_text required" id="FH_0_first_name"> <label for="FHE_0_first_name">First*<small></small></label> <div> <input type="text" title=""
<div class="FH_element FH_text required" id="FH_0_first_name">
<label for="FHE_0_first_name">First*<small></small></label>
<div>
<input type="text" title="" name="first_name" value="" tabindex="3" id="FHE_0_first_name">
</div>
</div>
首先*
在上面的代码中,我需要在jquery中使用div的类名(必选)查找文本框id(FHE_0_first_name)。使用非常特定的选择器:
<div class="FH_element FH_text required" id="FH_0_first_name">
<label for="FHE_0_first_name">First*<small></small></label>
<div>
<input type="text" title="" name="first_name" value="" tabindex="3" id="FHE_0_first_name">
</div>
</div>
jQuery('.required input').attr('id')
var textboxId = $('div.FH_element.FH_text.required')
.find('input[type="text"]')[0]
.id;
试试这个:
$('.required').find('input').attr('id')
这应该会有所帮助
var textBoxId = $('.required').find('input[type=text]').attr('id');
谢谢你的回应和帮助