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

查看所有标签

Boolean Reasoning

Boolean Reasoning

Brown, Frank Markham / 2003-4 / $ 19.15

A systematic treatment of Boolean reasoning, this concise, newly revised edition combines the works of early logicians with recent investigations, including previously unpublished research results. Th......一起来看看 《Boolean Reasoning》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具