单击由鼠标按下激活

Onclick activated by onmousedown

本文关键字:激活 鼠标 单击      更新时间:2023-09-26

有没有办法激活点击事件,例如

onClick="variable();size()"

哪里还有鼠标关闭事件?

class="div_1" onClick="variable();size()" onmousedown="clickin(this)" 

onmousedown javascript 将在哪里激活 onclick javascript?

function clickin(control) {
    var allElements = document.getElementById(control.id);
    for (var i=0; i<allElements.length; i++) { 
        eval(document.getElementById('elementId').getAttribute('onclick'));
    }
}

onclick属性通常会变成一个函数。所以这将起作用:

<a onclick="alert('click');" onmousedown="this.onclick()">Click here to click</a>

/编辑:

<a id="a_target">Click here to click</a>
<script type="text/javascript">
     var a_target = document.getElementById('a_target');
     a_target.onclick = function(){ alert('click'); };   // CODE TO ADD ONCLICK
     a_target.onmousedown = function(){ this.onclick();  } // CODE TO ADD MOUSEDOWN
     // TO REMOVE THEM DO THIS
     a_target.onclick = a_target.onmousedown = function(){} // NO MORE CLICKS
     a_target.onmousedown = function(){
          alert('mousedown!'); // DISPLAYS POPUP
          a_target.onmousedown = function(){} // STOPS FROM CLICK
          a_target.onclick = function(){ alert('CLICK :D'); } // WILL POPUP CLICK NOW AND ON NEXT CLICK
     }
     // TO POPUP CLICK ONLY ON NEXT CLICK CHANGE ONMOUSEDOWN TO ONMOUSEUP
</script>