venkat venkat - 1 year ago 127
jQuery Question

How to Get all nodeName inside div tag in jquery?

I need to get all elements

using jQuery. I am trying, yet I am only able to get a single element's

<div class="module">
<p class="aa">Lorem Ipsum</p>
<p>Lorem Ipsum</p>
<p>Lorem Ipsum <span>Test</span></p>
<span>This span</span>

thanks & regards

Answer Source

You can loop through the children() of the div, and retrieve the nodeName property from each, like this:

$('.module').children().each(function() {
    var nodeName = this.nodeName;

Working example

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download