Fixed typos and whitespace in jQuery selectors (#22053)
On line 8: "an function" changed to "a function" On line 83 & 84: "on the dom" changed to "in the dom" On line 89 & 97: removed whitespace in jQuery selectors
This commit is contained in:
@ -5,6 +5,7 @@ title: Click Method
|
|||||||
# Click Method
|
# Click Method
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The jQuery Click method triggers a function when an element is clicked. The function is known as a "handler" because it handles the click event. Functions can
|
The jQuery Click method triggers a function when an element is clicked. The function is known as a "handler" because it handles the click event. Functions can
|
||||||
impact the HTML element that is bound to the click using the jQuery Click method, or they can change something else entirely. The most-used form is:
|
impact the HTML element that is bound to the click using the jQuery Click method, or they can change something else entirely. The most-used form is:
|
||||||
|
|
||||||
@ -80,13 +81,13 @@ Also you should prefer to use .on('click',...) over .click(...) because the form
|
|||||||
|
|
||||||
#### Common Mistakes
|
#### Common Mistakes
|
||||||
|
|
||||||
The click event is only bound to elements currently on the DOM at the time of binding, so any elements added afterwards will not be bound. To bind all
|
The click event is only bound to elements currently in the DOM at the time of binding, so any elements added afterwards will not be bound. To bind all
|
||||||
elements on the DOM, even if they will be created at a later time, use the `.on()` method.
|
elements in the DOM, even if they will be created at a later time, use the `.on()` method.
|
||||||
|
|
||||||
For example, this click method example:
|
For example, this click method example:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
$( "element" ).click(function() {
|
$("element").click(function() {
|
||||||
alert("I've been clicked!");
|
alert("I've been clicked!");
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@ -94,7 +95,7 @@ $( "element" ).click(function() {
|
|||||||
Can be changed to this on method example:
|
Can be changed to this on method example:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
$( document ).on("click", "element", function() {
|
$(document).on("click", "element", function() {
|
||||||
alert("I've been clicked!");
|
alert("I've been clicked!");
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user