Can I track multiple events in an anchor in HTML?
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.
精彩评论