zoukankan      html  css  js  c++  java
  • javascript双击和单击事件共存

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title></title>
    <style>
            .quick{
     105px;
    height: 36px;
    background-image: url("ic_cloud_upload_white_24dp.png");
    background-repeat: no-repeat;
    background-color: black;
    cursor:pointer;
            }
            .quick img {
    visibility: visible;
    position: absolute;
            }
    
            .quick span {
    font-size: 14px;
    /*padding-top: 12px;*/
    float: right;
    color: white;
    line-height: 40px;
            }
            //这里为双击文字时,背景色不让其高亮
    body{-moz-user-select:none;}//火狐
    /*<body onselectstart="return false">*/其他浏览器
    </style>
    <script type="text/javascript">
    var clickTimer = null;
    function _click(){
    if(clickTimer) {
    window.clearTimeout(clickTimer);
    clickTimer = null;
                }
    
    clickTimer = window.setTimeout(function(){
    // your click process code here
    alert("你单击了我");
                }, 300);
            }
    function _dblclick(){
    if(clickTimer) {
    window.clearTimeout(clickTimer);
    clickTimer = null;
                }
    alert("你双击了我");
            }
    
    </script>
    </head>
    <body >
    <div onselectstart="return false" onclick="_click();" ondblclick="_dblclick();" class="quick"><img src="uploading.gif"><span>快捷上传</span></div>
    </body>
    </html>
     
    业勤于精荒于嬉 http://www.cnblogs.com/maxlei/
  • 相关阅读:
    Add source code and doc in maven
    Spring toturial note
    How to add local jar into maven project
    Ubuntu 12.04 下安装 Eclipse
    如何更改linux文件的拥有者及用户组(chown和chgrp)
    20非常有用的Java程序片段
    Java中的Set、List、Map的区别
    Java I/O知识点汇总
    Java I/O流整理
    hadoop2.0集群配置
  • 原文地址:https://www.cnblogs.com/maxlei/p/5954032.html
Copyright © 2011-2022 走看看