Reputation: 61
I need your help to find textbox id inside a div based on div's css class name in jquery.
<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>
In the above code i need to find the textbox id(FHE_0_first_name) using div's class name(required)..in jquery.
Upvotes: 2
Views: 19073
Reputation: 95
This should help
var textBoxId = $('.required').find('input[type=text]').attr('id');
Upvotes: 4
Reputation: 359876
Using very specific selectors:
var textboxId = $('div.FH_element.FH_text.required')
.find('input[type="text"]')[0]
.id;
Upvotes: 8