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

来源:互联网 发布:mac 网线转接头 编辑:程序博客网 时间:2024/05/20 18:43
<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>