Am new to JavaScript. Actually confused of 'this' keyword in javascript. If possible can anyone give me a brief idea about how to implement 'this' in the code.
this denotes current DOM object . for example function test(obj) { alert(obj.value); } <input type="text" id="testme" onblur="test(this)"/>
Even more, it doesn't have to be only DOM object. In general, it represents instance of any object. Usually, it is used in constructors for accessing attributes. You can look here: http://www.w3schools.com/js/js_objects.asp
this can be as the html element that called the event (onclick,onmouseover,etc.) Example: <input type="submit" onclick="return validate(this);" /> HTML: or this can be the object that contains a certain method/function. Example: var obj = new Object(); obj.text = "The text"; obj.getText = function(){ return this.text; } Code (markup):
In some case we use "this" word for forum. for example when we have to change the class of any tag dynamically or at the time of event then we use this.form_name.field element. This refer to object which we are going to change values