Sportica   Sportica

onmousedown 与onmouseup事件在一个按钮中同时调用

<html>
<head>
<title>test</title>
<link rel="stylesheet" type="text/css" href="./css/test.css" />
</head>

<script>
    function testdown()  //鼠标按下时
    {
        //alert("aaa");
        document.getElementById('txtptz').value=1;
    }
    function testup()  //鼠标松开时
    {
        //alert("aaa");
        document.getElementById('txtptz').value=2;
    }
</script>

<script type="text/javascript">
function mouseDownFun()
{
    document.getElementById('div1').innerHTML += 'mouseDown<br/>';
}

function mouseUpFun()
{
    document.getElementById('div1').innerHTML += 'mouseUp<br/>';
}

function clickFun()
{
    document.getElementById('div1').innerHTML += 'click<br/>';
}
</script>

<body>
    <p>test</p>
    <input type="test" id="txtptz" onmousedown="testdown();" onmouseup="testup();">
    <input id="testptz"  type="button" name="reset"  value="保存"  onmousedown="testdown();" onmouseup="testup();" >    
    <div id="div1" onmousedown="mouseDownFun();" onmouseup="mouseUpFun();" onclick="clickFun();" style="background:#CCC; border:3px solid #999; width:200px; height:200px; padding:10px"></div>

<input style="margin-top:10px" type="button" onclick="document.getElementById('div1').innerHTML='';" value="清除信息" />

</script>
  </div>
</body>
</html>


 
posted @ 2012-05-24 15:26  qingjoin  阅读(2195)  评论(0编辑  收藏  举报
  Sportica