当鼠标左键按住不放时,鼠标移动到按钮则触发按钮点击事件.若鼠标放开时,鼠标移动到按钮则不触发.

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="  http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="textml; charset=utf-8" />
    <title>无标题文档</title>
    </head><body>
    <div id="odiv" style="width:100px; height:100px; border:1px solid red">按住鼠标移上来</div>
    <script type="text/javascript">
    <!--
    var isBound = false;
    document.onmousedown = function(){
    isBound = true;
    }
    document.onmouseup = function(){
    isBound = false;
    }
    document.getElementById('odiv').onmouseover = function(){
    if(!!isBound)  this.style.backgroundColor = 'blue';
    }
    //-->
    </script>
    </body>
    </html>