Skip to content

Commit b2e0296

Browse files
AurelioDeRosatimmywil
authored andcommitted
jQuery.escapeSelector: Created entry
Fixes gh-880 Closes gh-934
1 parent a062f9f commit b2e0296

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

entries/jQuery.escapeSelector.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<entry type="method" name="jQuery.escapeSelector" return="Selector">
3+
<title>jQuery.escapeSelector()</title>
4+
<desc>Escapes any character that has a special meaning in a CSS selector.</desc>
5+
<signature>
6+
<added>3.0</added>
7+
<argument name="selector" type="Selector">
8+
<desc>A string containing a selector expression to escape.</desc>
9+
</argument>
10+
</signature>
11+
<longdesc>
12+
<p>This method is useful for situations where a class name or an ID contains characters that have a special meaning in CSS, such as the dot or the semicolon.</p>
13+
<p>The method is essentially a shim for the <a href="https://drafts.csswg.org/cssom/#the-css.escape()-method">CSS Working Group's CSS.escape() method</a>. The main difference is that <code>$.escapeSelector()</code> can be reliably used in all of jQuery's supported browsers.</p>
14+
</longdesc>
15+
<example>
16+
<desc>Escape an ID containing a hash.</desc>
17+
<code><![CDATA[
18+
$.escapeSelector( "#target" ); // "\#target"
19+
]]></code>
20+
</example>
21+
<example>
22+
<desc>Select all the elements having a class name of <code>.box</code> inside a <code>div</code>.</desc>
23+
<code><![CDATA[
24+
$( "div" ).find( "." + $.escapeSelector( ".box" ) );
25+
]]></code>
26+
</example>
27+
<category slug="css"/>
28+
<category slug="version/3.0"/>
29+
</entry>

0 commit comments

Comments
 (0)