$(this) Selector in jQuery
$(this) – selector is used to select the current element in the page.
Syntax : $(this) Selector in jQuery
$(this) Selector in jQuery Example
<!DOCTYPE html> <html> <head> <title>jQuery $(this) Example</title> <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"> </script> <script type="text/javascript"> $(document).ready(function(){ $("#demo").click(function(){ $(this).css("border","4px solid red"); $(this).css("color","black"); $(this).css("font-size","36px"); alert("You Invoked me And all properties are applied using $(this) reference"); }); }); </script> </head> <body> <a href="javascript:void(0)" id="demo"> Click this element to invoke me.. </a> </body> </html> |
Advertisements