jQuery jQuery.htmlPrefilter() 方法
jQuery 教程
· 2019-03-29 13:58:24
实例
从传入HTML字符串中删除所有标签
$(function() {
var htmlPrefilter = $.htmlPrefilter,
rdel = /<(del)(?=[\s>])[\w\W]*?<\/\1\s*>/gi;
$.htmlPrefilter = function( html ) {
return htmlPrefilter.call( this, html ).replace( rdel, "" );
};
var htm = '<del>删除</del><h1>标题</h2>';
$('body').append($.htmlPrefilter(htm));
});
定义和用法
$.htmlPrefilter() 函数通过jQuery操作方法修改和过滤HTML字符串。
注意:1. 这种方法很少需要直接调用,反而可以使用这个方法作为修改现有jQuery操作方法的一个切入点。
语法
$.htmlPrefilter( html )
| 参数 | 描述 |
|---|---|
| html | String类型 在该HTML字符串上进行操作 |
点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html
The Four
Scott Galloway / Portfolio / 2017-10-3 / USD 28.00
NEW YORK TIMES BESTSELLER USA TODAY BESTSELLER Amazon, Apple, Facebook, and Google are the four most influential companies on the planet. Just about everyone thinks they know how they got there.......一起来看看 《The Four》 这本书的介绍吧!