jQuery.htmlPrefilter()
jQuery.htmlPrefilter( html )Returns: String
Description: Modify and filter HTML strings passed through jQuery manipulation methods.
-
version added: 1.12/2.2jQuery.htmlPrefilter( html )
-
htmlType: StringThe HTML string on which to operate.
-
This method rarely needs to be called directly. Instead, use it as an entry point to modify existing jQuery manipulation methods. For instance, to remove all <del>
tags from incoming HTML strings, do this:
1
2
3
4
5
6
|
|
This function can also be overwritten in order to bypass certain edge case issues. The default htmlPrefilter
function in jQuery will greedily ensure that all tags are XHTML-compliant. This includes anything that looks like an HTML tag, but is actually within a string (e.g.
<a title="<div />"><>). The
jQuery.htmlPrefilter()
function can be used to bypass this:
1
2
3
4
|
|
However, while the above fix is short and simple, it puts the burden on you to ensure XHTML-compliant tags in any HTML strings. A more thorough fix for this issue would be this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
|