How do I remove HTML and special charaters using jQuery?

后端 未结 6 948
走了就别回头了
走了就别回头了 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:13

    Your code works, but it will remove the entire element. empty will remove all child nodes including text or nested elements.

    If you just wanted to remove all the text from elements containing dots you could do:

    $(":contains('•')").text();
    

    If you just wanted to get rid of the dots and leave everything else:

        $(":contains('•')").each(function() {
        var text = $(this).text();
        text.replace(/•/gi, ""))
        $(this).text(text);
        });
    

提交回复
热议问题