A question – how often do you go online to perform a task? I'll bet it's a fair few times a week; it could be anything from online banking, to hitting Amazon to get that latest DVD (DVDs – who downloads them, I wonder?)
That aside, we can't escape having to click on a link or a button to advance through a process. In most cases, the code behind the event is likely to be the ubiquitous click handler, or it could even be .change()
or .hover()
. All are shorthand forms of the .on()
(or even .off()
) event handlers, and are of course functionality equivalent to something like the following:
$('a').on('click', function(){ $(this).css('background-color','#f00'); });
This will turn the selected element to a nice shade of red. However, there is more to event handling than simply defining an action on a known element. Over the next few pages, we're going (to quote a nautical term) to push the boat out, and take a look at a few tips and tricks that we can use, to help develop...