Event driven programming with jQuery – (part 2). Events in jQuery.

Well the “native” events in JavaScript are ‘onlick’, ‘onmouseover’, etc. I’m pretty sure that the term ‘native’ is not quite descriptive. OK. However even this can be called event driven programming.

The jQuery as usual simplifies the usage of this events and their handling. If you’ve some DOM with id ‘a’, i.e.:

document.getElementById('a').onclick = func();

In jQuery this comes with no browser dependencies, like:

$('#a').click(func);

That normally means that on click of that element, with id ‘a’, calls the func() method.

The need of event driven programming with JavaScript and jQuery is because in large scale applications you don’t need only click events. You’d like to call some method to be called on array change, or on style change or whatever! Than you can start using custom events, where jQuery again helps you a lot.

I’ll demonstrate in my next post how this can be implemented in a short example application.

Leave a Reply

Your email address will not be published. Required fields are marked *