Possible Duplicate:
jQuery equivalent of JavaScript's addEventListener method
Also from a very good jQuery tutorial on : http://itunes.apple.com/in/app/designmobileweb/id486198804?mt=8
What is the jQuery equivalent for the following statement;
element1.addEventListener('click',doSomething2,false)
If it is the bind()
method, is there any option to specify the last parameter (i.e. event bubbling or capturing ... true/false)
Try this
// Setting the third argument to false will attach a function
// that prevents the default action from occurring and
// stops the event from bubbling.
$("#element1").bind("click", doSomething2, false);
Yes I'm pretty certain .bind() will work as you need it. Check out the jQuery .bind() docs page I'm sure you can figure out the setup. Demo code below:
$(document).ready(function() {
$("#element1").bind('click', function() {
// do something on click
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With