1.单双击事件的添加。
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>单双击事件</title> 6 </head> 7 <body> 8 <input type="button" onclick="return fun(1)" ondblclick="return fun(2)" value="按钮"> 9 <script> 10 var dblnum=0; 11 function fun(num){ 12 dblnum=num; 13 if(dblnum==1){ 14 window.setTimeout(function(){ 15 if(dblnum!=2){ 16 console.log(‘单机‘); 17 dblnum=0; 18 } 19 20 },500) 21 } 22 if(dblnum==2){ 23 console.log("双击"); 24 return false; 25 } 26 } 27 </script> 28 </body> 29 </html>
时间: 2024-12-28 23:17:40