This question already has an answer here:
(这个问题在这里已有答案:)
(如何在onclick事件中调用多个JavaScript函数?)
(10个答案)
HTML & JS
(HTML和JS)
How do I call 2 functions from one onclick event?
(如何从一个onclick事件中调用2个函数?)
(这是我的代码)
<input id ="btn" type="button" value="click" onclick="pay() cls()"/>
the two functions being pay() and cls().
(这两个函数是pay()和cls()。)
(谢谢!)
Add semi-colons ;
;
(添加分号;)
(到函数调用结束,以便它们都能工作。)
<input id="btn" type="button" value="click" onclick="pay(); cls();"/>
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
(以下是SitePoint http://reference.sitepoint.com/html/event-attributes/onclick的一个很好的参考)
2.1m questions
2.1m answers
60 comments
57.0k users