Skip to content Skip to sidebar Skip to footer

Hide Elements (

) In A Column

I'm using Knack Online Database to create apps. I'm trying to find a way to hide empty space in a cell. I have a table that has a text formula. The text formula combines multiple f

Solution 1:

Perhaps something like this in your CSS?

b:empty + br:empty,
b:empty {
  display: none;
}

This would hide every empty <b> tag and any empty <br> placed after an empty <b>.

Here's a fiddle.

Solution 2:

Could you try something like this?

var empties = jQuery("b:empty");
var nextsBr = empties.next().filter('br');
nextBr.remove();
empties.remove();

Solution 3:

You can use :empty and siblings selectors

$('b:empty').remove()

$('br + br').remove()
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><b>question1</b> answer1
<br><b></b><br><b>question2</b> answer2
<br>

Solution 4:

$('b').each(function() {
    if ( $.trim( $(this).text() ).length == 0 ) {
        if ( $(this).children().length == 0 ) {
            $(this).text('');
            $(this).remove(); // remove empty paragraphs
        }
    }
});

Taken from here.

Post a Comment for "Hide Elements (

) In A Column"