如何在HTML或JavaScript中按钮的onclick方法调用两个方法? [英] How to call two methods on button's onclick method in HTML or JavaScript?
本文介绍了如何在HTML或JavaScript中按钮的onclick方法调用两个方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在HTML或JavaScript的按钮的onclick方法中调用两种方法? p>试试这个:
< input type =buttononclick =function1(); function2(); value =Call2Functions/>
或者,在第一个函数结束时调用第二个函数:
$ b $
函数func1(){
// ---一些逻辑
func2();
函数func2(){
// ---一些逻辑
}
...并且调用func1()onclick按钮:
< ; input type =buttononclick =func1(); value =Call2Functions/>
How to call two methods on button's onclick method in HTML or JavaScript ?
解决方案
Try this:
<input type="button" onclick="function1();function2();" value="Call2Functions" />
Or, call second function at the end of first function:
function func1(){ //--- some logic func2(); } function func2(){ //--- some logic }
...and call func1() onclick of button:
<input type="button" onclick="func1();" value="Call2Functions" />
这篇关于如何在HTML或JavaScript中按钮的onclick方法调用两个方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文