如何在 onclick 事件中调用多个 JavaScript 函数? [英] How to call multiple JavaScript functions in onclick event?

查看:25
本文介绍了如何在 onclick 事件中调用多个 JavaScript 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法可以使用onclick html 属性来调用多个JavaScript 函数?

Is there any way to use the onclick html attribute to call more than one JavaScript function?

推荐答案

onclick="doSomething();doSomethingElse();"

但实际上,您最好根本不使用 onclick 并通过您的 Javascript 代码将事件处理程序附加到 DOM 节点.这称为非侵入式javascript.

But really, you're better off not using onclick at all and attaching the event handler to the DOM node through your Javascript code. This is known as unobtrusive javascript.

这篇关于如何在 onclick 事件中调用多个 JavaScript 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆