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

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

问题描述

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

解决方案

  onclick =doSomething(); doSomethingElse(); 

但实际上,最好不要使用 onclick ,并通过您的Javascript代码将事件处理程序附加到DOM节点。这被称为不显眼的JavaScript

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

解决方案

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

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天全站免登陆