Javascript Onclick事件 [英] Javascript Onclick event
本文介绍了Javascript Onclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在按钮的OnClick事件中调用两个javascript函数。
如果可能,我该如何实现呢。请帮助我
Is it possible to call two javascript function in a button''s OnClick event.
If possible how can I implement this.Please help me
推荐答案
见下文..
1.通过客户端点击事件
See below..
1. Through on client click event
<script type="text/javascript">
function myfunc1()
{
alert('function 1');
}
function myfunc2()
{
alert('function 2');
}
</script>
以下Html ..
Html below..
<asp:button id="Button1" runat="server" text="Button" onclientclick="myfunc1(), myfunc2()" xmlns:asp="#unknown" /> // calling two functions
2.通过JQuery按钮单击事件
2. Through JQuery button click event
<script type="text/javascript">
function myfunc1()
{
alert('function 1');
}
function myfunc2()
{
alert('function 2');
}
(document).ready(function()
{
(document).ready(function() {
(#Button2)。click( function()
{
myfunc1();
myfunc2();
});
});
< / script >
("#Button2").click(function() { myfunc1(); myfunc2(); }); }); </script>
以下Html ..
Html below..
<asp:button id="Button2" runat="server" text="Button" xmlns:asp="#unknown" />
希望它可以帮助你..
Hope it helps you..
这篇关于Javascript Onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文