WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] hide empty selectors with jquery in wordpress (4 posts)

  1. spook80
    Member
    Posted 3 years ago #

    I have a question about using jquery - to hide empty selectors.
    do you know if its possible to hide a <h4 class="describe">FEATURES</h4> (h4.describe)ONLY when it's empty eg. <h4 class="describe"></h4>.
    only reason is because I put a border of one pixel on it and want to keep the border and background image.

  2. Michael Fields
    Themer
    Posted 3 years ago #

    This worked for me:

    jQuery( document ).ready( function( $ ) {
    	$( '.describe' ).each( function( i, e ) {
    		var h = $( e );
    		if ( '' === h.html() ) {
    			h.hide();
    		}
    	} );
    } );
  3. spook80
    Member
    Posted 3 years ago #

    Thankyou - Better then using CSS3 h4.describe:empty {display:none}

  4. Michael Fields
    Themer
    Posted 3 years ago #

    You're welcome :)

Topic Closed

This topic has been closed to new replies.

About this Topic