Question about javascript links
this because this bound to a global object inside setTimeout calls. It follows that both
setTimeout($('a').hide, 2000) and
setTimeout(function(){ $('a').hide(); }, 2000) will call the metos method $('a').hide , but with different values ββfor this ( window in the first case and $('a') in the second).
Here is more detailed information on the value of this according to how you call the function.
The expression $('a').hide returns the standard jQuery hide function without reference to $('a') .
When you call $('a').hide() as an instruction, $('a') is passed as the this parameter to hide .
However, when you pass the hide function to setTimeout , it does not call the function on $('a') ; all setTimeout 'd functions are called on window .
And if you want your line of code to work, you should quote it:
setTimeout("$('a').hide()", 2000) OR Take a look at: http://www.w3schools.com/jsref/met_win_settimeout.asp