Posted On: Feb 22, 2018
$(document).ready(function(){ $('#clickme').click(function(){ alert($(this).text()); alert(this.innerText); }); });
this and $(this) references the same element but the difference is that “this” is used in traditional way but when “this” is used with $() then it becomes a jQuery object on which we can use the functions of jQuery.?
In the example given, when only “this” keyword is used then we can use the jQuery text() function to get the text of the element, because it is not jQuery object. Once the “this” keyword is wrapped in $() then we can use the jQuery function text() to get the text of the element.
Never Miss an Articles from us.
jQuery is a lightweight JavaScript library which gives a quick and simple method for HTML DOM traversing and manipulati..
There are many advantages of JQuery. Some of them are :It is more like a JavaScript enhancement so there is no overhea..
There are 3 types of selectors in JqueryCSS Selector XPath Selector Custom Selector..