Alex Rivera | Logout

Check whether a DIV contains Image or not

Asked 2013-01-18T12:20:32.537
11

I am trying to determine whether a DIV has a image or not. Structure of my DIV is as:

<li class="customData">
  <div class="customdata1"><img src="" /></div>
  <div class="customdata1"><input type="text" /></div>
</li>
Edit
Report

1 Answer

11

You can use the has() selector

$('.customData div:has(img)').doSomething()

Not sure what you want to do, if you wanted to count them for example:

  alert(  $('.customData div:has(img)').length)

API Refrence http://api.jquery.com/has-selector/

answered 2013-01-18T12:34:23.413

Your Answer