html - make the 'this' keyword refer to the calling object (javascript) -


I have read some topics about this, however, I still can not understand it. Just what I want what is giving 'this' statement gives context to the object that is calling the function, while it talks about the window ..

My function looks like this:

  function bckClr (clr) {var elmnt = this; Elmnt.style.background color = clr; }   

And I call it like this:

  & lt; Div & gt; Onmouseover = "bckClr (# ff0000)" & gt; Lorim Advertising Dolter Site Atom ..     

Do this like this:

  & Lt; Div onmouseover = "bckClr (this, '# FF0000')" & gt; Lorim Ipsum Dollar Ast Amit .. & lt; / Div & gt;   

And then:

  function bckClr (elmnt, clr) {elmnt.style.backgroundColor = clr; } Update:  Update:  
Updated by using Camel Sees for the surplus property noted by Pranav Kapoor.

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -