Q:

Jquery how to select all element but children

I have a code like that:
<div id="mn">

   <span></span>
   <span> <span></span></span>
   <span></span>
   <span> <span></span></span>
   <span></span>

</div>

when i use:
$("#mn").each(function(index, element) {

)};

it selects all span tags and span inside span tags, how do i select only parents span tags.

A:

you can do this way:
$("#mn > span").each(function(index, element) {

)};

This will only give immediate child span elements.
JQUERY DOCS

