What is the best way to call two functions upon a single click event?
There will be multiple elements requiring this script, so the script must act only upon the element being clicked — not all the elements at once.
Let me know if I need to provide more details. Thanks again for all your help.
$(function() {
$('a').click(function() {
func1();
func2();
});
});
jQuery will handle that for you quite nicely, see example:
$('div').click(function(){
alert($(this).text()+' clicked');
})
.click(function(){
$(this).css({'color':'#ff0000'});
});
<div>Button 1</div>
<div>Button 2</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Here's a jsFiddle example: http://www.jsfiddle.net/pcASq/
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