Today I was working on new category browser UI for the project I am working. I had to select the innermost element and append some more content into it. Basically, I had an HTML like this:
<div>Outermost element <div>Some Text <div>Evenmore text <div>Who cares anymore? <div>Innermost Element</div> </div> </div> </div> </div>
So I needed to select the innermost div and append another div to it. There is no jQuery selector but you can use selectors that exist to achieve this goal. The innermost element would be the last div with the only-child.
$('div:only-child:last'); // Change background color to gray $('div:only-child:last').css('background-color',"#ccc");