Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove <p> &nbsp;</p> with jquery if no value

how to hide attributes if detect this <p> &nbsp;</p>

My problem is when my client insert data(example table) with ckeditor , when i see the source code , ckeditor will add this <p> &nbsp;</p> after table code. i know how to remove this manualy with source code(open source code and delete) but not my client!

like image 777
ruslyrossi Avatar asked Dec 06 '22 15:12

ruslyrossi


1 Answers

Orignal answer : How do I remove empty p tags with jQuery?

Try

$('p').each(function() {
 var $this = $(this);
 if($this.html().replace(/\s|&nbsp;/g, '').length == 0)
     $this.remove(); }); 

here is working code : http://jsfiddle.net/ambiguous/7L4WZ/

like image 119
Pranay Rana Avatar answered Dec 31 '22 03:12

Pranay Rana