开发者

Can I track multiple events in an anchor in HTML?

开发者 https://www.devze.com 2023-04-10 11:50 出处:网络
Can I track multiple events in an anchor in HTML? Im already have an onClick event being tracked, but I want to track onRelease as well.

Can I track multiple events in an anchor in HTML?

Im already have an onClick event being tracked, but I want to track onRelease as well.

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>

Cou开发者_C百科ld 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.

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

  • onclick
  • ondblclick
  • onmouseup
  • onmousedown
  • onmouseover
  • onmouseout
  • onmousemove


I'm pretty sure that you can track as many events as you want (although I'm not sure that onRelease is actually an event), but let's find out.

0

精彩评论

暂无评论...
验证码 换一张
取 消