jquery - Remove or hide a div if it's empty -


i know should simple can't figure out. here's code.

<div class="cols lmenu_item1" id="leftmenuwrapper"> <div id="leftmenu"></div> </div> 

i need remove "leftmenuwrapper" if "leftmenu" empty. here's i've been using.

$('#leftmenu').empty().remove('#leftmenuwrapper'); 

sorry if simple question. having monday!

thanks!

you can this:

$('#leftmenu:empty').parent().remove(); 

this selects #leftmenu if it's :empty, , grabs .parent() of that .remove(). if wasn't empty, first selector won't find anything, or parent remove either.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -