Determining if a div contains a table element in JQuery

Posted by fishiefishie on Stack Overflow See other posts from Stack Overflow or by fishiefishie
Published on 2010-04-22T00:00:43Z Indexed on 2010/04/22 0:03 UTC
Read the original article Hit count: 168

Filed under:

For my accordion, each time the user clicks on the header, i want to see if accordion-content contains a table, if not, generate one and add it to accordion-content. But how do you check if the current element contains a certain type of element?

   <div class="a-header"> 
      <ul><li></li></ul>
    </div>
    <div class="a-content">
    </div>

    $('.a-header').click(function(){
       var currentHeader = $(this).next();
       //if currentHeader contains 'table'
});

Thanks.

© Stack Overflow or respective owner

Related posts about jQuery