简体   繁体   English

我可以在HTML锚中跟踪多个事件吗?

[英]Can I track multiple events in an anchor in HTML?

Can I track multiple events in an anchor in HTML? 我可以在HTML锚中跟踪多个事件吗?

Im already have an onClick event being tracked, but I want to track onRelease as well. 我已经有一个onClick事件被跟踪,但我也想跟踪onRelease。

If so whats the best way to do it? 如果是这样,最好的方法是什么?

This is a basic example of how I have it implemented: 这是我如何实现的基本示例:

<a href="#" onclick="function();" class="pickbutton hidden-text" id="120btn">120</a>

Could this work? 这行得通吗?

<a href="#" onclick="function1();" onRelease="function2();" class="pickbutton hidden-text" id="120btn">120</a>

You can attach as many events as you like. 您可以附加任意数量的事件。 The preferred way to attach events is to do it in a javascript file, or tag, rather than as attributes on the element. 附加事件的首选方法是在javascript文件或标记中进行,而不是作为元素上的属性。

foo = getElementById('my_element_id');
foo.addEventListener('eventName', functionToExecute);

This is much easier with a framework such as query. 使用查询之类的框架,这要容易得多。

$('#my_element_id').bind('eventName', functionToExecute);

Check out mouse eventsat quirksmode or w3schools 看看鼠标eventsat 怪异模式W3Schools的

  • onclick 点击
  • ondblclick ondblclick
  • onmouseup 鼠标悬停
  • onmousedown 鼠标停下
  • onmouseover 鼠标悬停
  • onmouseout 暂停
  • onmousemove 情绪激动

我非常确定您可以跟踪任意数量的事件(尽管我不确定onRelease实际上是一个事件),但是让我们来找出答案

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM