+ 4
How to use (this) in javascript?
as the title describes i never able to find out how to use this "this" in javascript or ajax or jquery its pritty confusing and i am worries because it makes my programming base week. so i want to know what it is and how to use it?
2 Answers
+ 6
HTML :
<p>Hello</p>
You want to change the above text to red onclick, so you use the selector first.
jQuery :
$(function() {
$("p").on("click", function() {
$(this).css("color", "red")
})
})
The point is to recall the previous selector.
+ 1
okk