how to remove   and
using javascript or jQuery?

前端 未结 8 1081
心在旅途
心在旅途 2020-12-06 05:38

I have written the following code. But it is removing only   not

var docDesc = docDescription.replace(/(&nb         


        
相关标签:
8条回答
  • 2020-12-06 06:08

    What about:

    var docDesc1 = docDescription.replace(/(<br ?\/?>)*/g,"");
    
    0 讨论(0)
  • 2020-12-06 06:14

    I using simple replace to remove &nbsp; and br tag.

    JavaScript

    var str = docDescription.replace(/&nbsp;/g, '').replace(/\<br\s*[\/]?>/gi, '');
    

    jQuery

    Remove br with remove() or replaceWith()

    $('br').remove();
    

    or

    $('br').replaceWith(function() {
      return '';
    });
    
    0 讨论(0)
提交回复
热议问题