Skip to content

Commit 55cb98c

Browse files
committed
has-attribute selector: Make use of ".one()" explicit for example
1 parent c21b787 commit 55cb98c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

entries/has-attribute-selector.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
<desc>Selects elements that have the specified attribute, with any value. </desc>
1212
<longdesc/>
1313
<example>
14-
<desc>Bind a single click that adds the div id to its text.</desc>
14+
<desc>Bind a single click to divs with an id that adds the id to the div's text.</desc>
1515
<code><![CDATA[
16+
// Using .one() so the handler is executed at most once
17+
// per element per event type
1618
$( "div[id]" ).one( "click", function() {
1719
var idString = $( this ).text() + " = " + $( this ).attr( "id" );
1820
$( this ).text( idString );

0 commit comments

Comments
 (0)