简体   繁体   English

是否可以在一个html事件上调用两个javascript函数?

[英]Is it possible to call two javascript functions on one html event?

I'm trying something like this: 我正在尝试这样的事情:

<textarea onFocus = "myFunction(1)" onBlur = "myFunction(0); return submitform();">

Is this possible? 这可能吗?

Yes but the syntax is wrong, see this edited textarea: 是的,但语法错误,请参阅此编辑的textarea:

 <textarea onfocus="myFunction(1);" onblur="myFunction(0); return submitform();">
             ^------                  ^-------- small letter is important

A yet better way would be to attach jQuery event handlers, or similiar with a different preferred framework. 更好的方法是附加jQuery事件处理程序,或者类似于不同的首选框架。

Yes you can. 是的你可以。 The text between the two "" is actually considered as a function. 两个“”之间的文本实际上被视为一个函数。 So it is a unnamed function calls your other functions. 所以它是一个未命名的函数调用你的其他函数。

Answer given by @DanFromGermny is right, @DanFromGermny给出的答案是对的,

you can try this also 你也可以尝试一下

<textarea onfocus="myFunction(1);" onblur="(function(){myFunction(0); return submitform();})(event)">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 html 中的同一 onclick 事件属性上调用两个不同的 JavaScript 函数,一个用于桌面版本,一个用于移动版本? - How to call two different JavaScript functions, one for desktop version and one for mobile version on a same onclick event attribute in html? 无法在javascript onclick事件上调用两个函数 - unable to call two functions on javascript onclick event 通过一个按钮调用两个JavaScript函数 - Call two JavaScript functions from one button 依次在javascript中的同一onclick事件上调用两个不同的函数 - Call two different functions on same onclick event in javascript one after another 如何在单个事件上调用两个函数。 一个作为javascript函数,另一个是服务器端函数 - How to call two functions on single event. one as a javascript function other a server side function 如何调用两个函数:Java和Javascript,在InputText上具有一个KeyUp事件 - how can I call two functions: Java and Javascript with one KeyUp event on InputText 一次调用两个函数 - Two functions in one call 如何从onchange事件中调用javascript中的两个函数 - How to call two functions in javascript from onchange event 如果在JavaScript中单击按钮事件时调用两个函数会发生什么 - What happens if call two functions when button click event in javaScript 一组arguments可以同时调用两个函数吗? - Is it possible to call two functions at the same time with one set of arguments?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM