How do I remove HTML and special charaters using jQuery?

后端 未结 6 1013
走了就别回头了
走了就别回头了 2021-01-29 11:44

So what I want to do is remove all of the HTML table tag elements, leaving the link tags alone.


&l         
6条回答
  •  天涯浪人
    2021-01-29 12:25

    The question was changed to ask something completely different after this answer was posted.

    See @T.J.'s answer for a solution to the new question.


    Do it with — gasp, shock horror — vanilla JavaScript!

    var $headlines = $('.headlines'),
        headlineText = $headlines.text(),
        replaceText = headlineText.replace(/•/g, '');
    
    $headlines.text(replaceText);
    

    or, slightly sexier syntax:

    $('.headlines').text(function (index, text)
    {
        return text.replace(/•/g, '');
    });
    

提交回复
热议问题