Thursday 12 December 2013

Hide Empty Divs

This post is for my Reference to comeback when its required :)
Problem:
So if you have a page and have div tags which are empty and some styles are applied on it, It would take some padding and margin around it and the page layout will look bad.
Solution:
jQuery:
$('div').filter(function() {
  return $.trim($(this).text()) === ''
}).remove()

Can see the Implementation in: JSFiddle 

No comments:

Post a Comment