This question already has an answer here:
HTML & JS
How do I call 2 functions from one onclick event? Here's my code
<input id ="btn" type="button" value="click" onclick="pay() cls()"/>
the two functions being pay() and cls(). Thanks!
This question already has an answer here:
HTML & JS
How do I call 2 functions from one onclick event? Here's my code
<input id ="btn" type="button" value="click" onclick="pay() cls()"/>
the two functions being pay() and cls(). Thanks!
You can call the functions from inside another function
Add semi-colons
;
to the end of the function calls in order for them both to work.I don't believe the last one is required but hey, might as well add it in for good measure.
Here is a good reference from SitePoint http://reference.sitepoint.com/html/event-attributes/onclick
Binding events from html is NOT recommended. This is recommended way:
You can create a single function that calls both of those, and then use it in the event.
And then, for the button:
put a semicolon between the two functions as statement terminator.
With jQuery :