开发者

remove a set of characters from a script [duplicate]

开发者 https://www.devze.com 2023-04-10 21:12 出处:网络
This question already has answers here: Strip HTML from Text JavaScript (45 answers) 开发者_运维知识库
This question already has answers here: Strip HTML from Text JavaScript (45 answers) 开发者_运维知识库 jQuery (almost) equivalent of PHP's strip_tags() (9 answers) Closed 9 years ago.

How to remove <p> and </p> from a text in javascript?

I have a string

 <p> This is a text</p>

and I want to remove the <p> and the </p>.

How can I do that in Javascript?


Use the replace() function.

For example: "<p> This is a text</p>".replace(/<\/?p>/g,"").

0

精彩评论

暂无评论...
验证码 换一张
取 消