Skip to content

Commit 29d5696

Browse files
committed
Note that html('content') removes previous data/events.
Fixes jquery#69
1 parent ee4ebae commit 29d5696

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

entries/html.xml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,22 @@ $("p").click(function () {
5757
<signature>
5858
<added>1.4</added>
5959
<argument name="function(index, oldhtml)" type="Function">
60-
<desc>A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, <code>this</code> refers to the current element in the set.</desc>
60+
<desc>A function returning the HTML content to set. Receives the
61+
index position of the element in the set and the old HTML value as arguments.
62+
jQuery empties the element before calling the function;
63+
use the oldhtml argument to reference the previous content.
64+
Within the function, <code>this</code> refers to the current element in the set.</desc>
6165
</argument>
6266
</signature>
6367
<desc>Set the HTML contents of each element in the set of matched elements.</desc>
6468
<longdesc>
6569
<p>The <code>.html()</code> method is not available in XML documents. </p>
66-
<p>When <code>.html()</code> is used to set an element's content, any content that was in that element is completely replaced by the new content. Consider the following HTML:</p>
70+
<p>When <code>.html()</code> is used to set an element's content,
71+
any content that was in that element is completely replaced by the new content.
72+
Additionally, jQuery removes other constructs such as data and event
73+
handlers from child elements before replacing those elements with the new content.</p>
74+
75+
<p>Consider the following HTML:</p>
6776
<pre><code>&lt;div class="demo-container"&gt;
6877
&lt;div class="demo-box"&gt;Demonstration Box&lt;/div&gt;
6978
&lt;/div&gt;</code></pre>
@@ -113,4 +122,4 @@ $("p").click(function () {
113122
<category slug="version/1.0"/>
114123
<category slug="version/1.4"/>
115124
</entry>
116-
</entries>
125+
</entries>

0 commit comments

Comments
 (0)