How to find the deepest child of a div with jquery
<p>I'm trying to find the deepest element in the specified <code>div</code>with jquery. But the code which used is producing the <code>error</code> <code>TypeError: parent.children is not a function</code>.</p>

<p>I found this code from this <a href="http://stackoverflow.com/questions/4188933/how-do-i-select-the-innermost-element">link</a></p>

<p>the code is :</p>

<pre><code>function findDeepestChild(parent) {

    var result = {depth: 0, element: parent};

    parent.children().each(         //Here I getting the error TypeError: parent.children is not a function
        function(idx) {
            var child = $(this);
            var childResult = findDeepestChild(child);
            if (childResult.depth + 1 &gt; result.depth) {
                result = {
                    depth: 1 + childResult.depth, 
                    element: childResult.element};
            }
        }
    );

    return result;
}
---------------------------------------------------------------------------------------
        $(document).on('keypress','#sendComment', function(e) {
    if(e.keyCode==13){
        var itemId=$('#findbefore').prev('.snew').attr('id');//
        var item=findDeepestChild(itemId);
        alert(item);
    }
});
</code></pre>

<p>And my <code>divs</code> are :</p>

<pre><code>  &lt;div id="S04" class="snew" style="display: block;"&gt;
  &lt;div class="author-image"&gt;
  &lt;span&gt;vvvvvvvvvdfdfdf&lt;/span&gt;
  &lt;div class="s-content"&gt;&lt;/div&gt;
  &lt;div class="s-message"&gt;&lt;/div&gt;0
  &lt;div class="shpicture"&gt;
  &lt;img width="100%" height="100%" data-shareid="1" data-alid="1" data-id="1" alt="xyz" src="data:image/jpeg;base64,&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
</code></pre>

<p>I need to find the <code>img</code> from these.</p>

<p>please anyone help me .... Thanks ...</p>
