I was thinking that, if we add this attribute to a element’s onlick event like onclick="a=this". In this step are selecting the “p” element or the variable a can be used as an alternative to this.
See this code-
<p onclick="a=this">Click me to assign value<b> this</b> to variable<b> a</b></p>
<p>This is Another paragraph will this be affected</p>
<button onclick="a.style.visibility='hidden'">
When this button will be clicked, what will happen?, "button" will become invisible or "p"
</button>
Suppose if we click on the first paragraph and then click on the button which element/elements will become invisible. Will the button get affected from it or the first paragraph or may be the other paragraph as well?
I used Google to find more on this topic but didn’t got anything.
Yep, it will hide the first paragraph as you’re assign
thisas a global variablea: http://jsfiddle.net/cJDNf/