<div class="formSortable ui-sortable">
<div id="formItem_c_firstName" class="formItem leftLabel selected">
<label class="varcharIcon">First Name</label>
<div class="formInputBox">
<input type="text" id="Name" >
</div>
</div>
</div>
formSortable class child class formItem having selected class or not my jquery is
if ($('.formSortable').find('formItem').hasClass('selected')) {
alert("hi");
}
This:
if( $('.formSortable').find('.formItem.selected').length > 0 ) {
alert( 'hi' );
}
Or this:
$('.formSortable').find('.formItem.selected').length == 0 || alert( 'hi' );
Should work fine.
But if per the title you really meant child of '.formSortable' then use .children()
instead of .find()
:
if( $('.formSortable').children('.formItem.selected').length > 0 ) {
alert( 'hi' );
}
Or:
$('.formSortable').children('.formItem.selected').length == 0 || alert( 'hi' );
if ($('.formSortable').find('.formItem').hasClass('selected')) {
alert("hi");
}
you have missed the . before formitem .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With