What is the difference between this and $(this) in jQuery?
<button id="b" data-name="Save">Click</button>
$('#b').on('click', function () {
console.log(this.id); // DOM property
console.log($(this).data('name')); // jQuery method
console.log(this === $(this)[0]);
});
$('#b').click();
Console output
b
Save
true
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |