JavaScript module for stripping HTML tags and/or HTML element attributes from strings.

安装

npm install js-striphtml

使用

var striphtml = require('js-striphtml');
striphtml.striptags('<body>I am a <b>HTML</b> string.<div class="clear"></div></body>', [ 'b' ]);
// Returns "I am a <b>HTML</b> string."
var striphtml = require('js-striphtml');
striphtml.stripAttr('<p style="background:green">I am a <b>HTML</b> string. <img src="stringimg.jpg" align="right" /></p>', { 'img': [ 'src' ] } );
// Returns "<p>I am a <b>HTML</b> string. <img src="stringimg.jpg" /></p>"

相关文章:

  • 2021-11-16
  • 2021-06-02
  • 2021-10-04
  • 2021-11-17
  • 2021-10-29
  • 2021-11-22
  • 2021-11-11
猜你喜欢
  • 2022-02-08
  • 2022-01-30
  • 2022-12-23
  • 2021-11-13
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案