This seems a little silly to even mention here, but some people don’t now how to actually trigger events for which they’ve sculpted all that nifty jQuery code functionality for.
It’s actually really simple to be honest. You know that $(‘#button’).click(function(){ alert(‘button clicked!’); }); code you just wrote into your page?
Well try running $(‘#button’).click(); – yes that’s right, the function you previously wrote just got triggered, didn’t it?
And this applies for most events which you create actions for. Calling the event function with a parameter basically means you are creating a handle for when that event is triggered. Calling the event function without any parameters is tantamount to triggering that event.
Simple, but missed by a surprisingly large amount of people! :)
Related Posts :
To bind a hover effect, in other words a mouse over and mouse out event that goes together, to a ...
Before jQuery's native live() and delegate() functions came into being, the default for handling ...
I stumbled upon this frankly excellent, though unfortunately generically named, jQuery color pic ...
Sometimes you just don't want to use the good old anchor tag and want to use a tag instead, bu ...
The excellent and rather flexible jQuery plugin FancyBox has become my defacto jQuery lightbox i ...






