Hints
"this" selector used to take the current selector.For example
$("div.exam").click(function(){
$(this).next().css("color","red");
});
In the above code this is equal to "div.exam".
Note: for this no need of double quotes.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | < html >
< head >
< title >HTML-JQuery</ title >
< script type = "text/javascript" >
$(function () {
$("div.exam").click(function () {
$(this).next().css("color", "red");
});
});
</ script >
</ head >
< body >
< div class = "exam" >Click here to make next element red.</ div >
< div >Hello i become red</ div >
</ body >
</ html >
|
|