Skip to content

Noted support of SVG documents for class methods #886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions entries/hasClass.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $( "#mydiv" ).hasClass( "bar" )
<pre><code>
$( "#mydiv" ).hasClass( "quux" )
</code></pre>
<p>As of jQuery 1.12/2.2, this method supports XML documents, including SVG.</p>
</longdesc>
<example>
<desc>Looks for the paragraph that contains 'selected' as a class.</desc>
Expand Down
2 changes: 2 additions & 0 deletions entries/toggleClass.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
</signature>
<desc>Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.</desc>
<longdesc>
<p>Before jQuery version 1.12/2.2, the <code>.toggleClass()</code> method manipulated the <code>className</code> <em>property</em> of the selected elements, not the <code>class</code> <em>attribute</em>. Once the property was changed, it was the browser that updated the attribute accordingly. An implication of this behavior was that this method only worked for documents with HTML DOM semantics (e.g., not pure XML documents).</p>
<p>As of jQuery 1.12/2.2, this behavior is changed to improve the support for XML documents, including SVG. Starting from this version, the <code>class</code> <em>attribute</em> is used instead. So, <code>.toggleClass()</code> can be used on XML or SVG documents.</p>
<p>This method takes one or more class names as its parameter. In the first version, if an element in the matched set of elements already has the class, then it is removed; if an element does not have the class, then it is added. For example, we can apply <code>.toggleClass()</code> to a simple <code>&lt;div&gt;</code>: </p>
<pre><code>
&lt;div class="tumble"&gt;Some text.&lt;/div&gt;
Expand Down