How to retrieve class names of all child elements at multiple level in jquery?
<p>I want to retrieve class names of child elements at multiple level. I'm trying following, but it only gives the class names of rear child elements. What am I doing wrong ?</p>

<pre><code>    &lt;script type="text/javascript"&gt;
    $(document).ready(function(){
    thisP=$("#myParagraph");
    getChildStyles(thisP);
   //function 
function getChildStyles(thisobj) {
var classNames;
var classNames1; 
$(thisobj).children().each(function(){  
    classNames+=$(this).attr('class');
    if($(this).children().length&gt;0) {
            classNames1+=getChildStyles($(this));
        }
        classNames+=classNames1;        
    });
    return classNames;
}   
});
&lt;/script&gt;
</code></pre>

<p>And the HTML, </p>

<pre><code>   &lt;ul id="myParagraph" class"mainUL"&gt;
   &lt;li id="LIOne"&gt;ksjdfhsdf&lt;/li&gt;
   &lt;li id="LITwo"&gt;skdjfkdsf&lt;span class"span1Class"&gt;&lt;span class="span2class"&gt;&lt;/span&gt;  
   &lt;/span&gt;&lt;/li&gt;
   &lt;li id="LIThree" class="thirdLIClass"&gt;edroiutret&lt;/li&gt;
   &lt;/ul&gt;
</code></pre>
