if the empty h3 tag exists in the DOM you can test the length of text
within it. using theoretical class of "postDiv" loop through all the postDiv h3's: $(".postDiv h3").each(function() { // "each" loops through all matching selectors one at a time if( $(this).text().length==0 ){ // "this" refers to the individual h3 that is currently within the "each" $(this).closest(".postDiv").hide() // 'closest" looks up through parents to find match } }); mockaccino wrote: Hi, I'm a newbie to the concepts of programming let alone query and I was wondering if this was possible.I've got a Wordpress site that has a h3 tag nested inside a div. The problem is that a post is removed everyday which leaves the h3 empty but the div is still there taking up real estate making the columns uneven. So im thinking that there must be something like "if h3 is empty, hide div.class"whatever"... My embarrassing lame attempts don't work and i was wondering if someone can a tleast point me to the right function to try write something around. Thanks for taking the time to read this post. |
- [jQuery] Code to remove div when h3 is empty mockaccino
- Re: [jQuery] Code to remove div when h3 is empty Charlie