JavaScript实现长按事件
这方式太粗暴 , 肯定还有简单的方式请朋友们告知
<!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="text/html; charset=utf-8" />
<title>test长按</title>
<style>
textArea{}
</style>
</head>
<body>
<textArea id=a rows=200 cols=20 ></textArea>
<textArea id=b rows=200 cols=20 ></textArea>
</body>
<script>
var a = document.getElementById("a");
var b = document.getElementById("b");
// 给a添加长按事件和点击事件
addLongDown(a , function(e){
this.value += "长按\n";
});
a.addEventListener('click' , function(){
this.value += "点击\n";
})
// 给b添加长按事件和点击事件
addLongDown(b , function(e){
this.value += "长按\n";
});
b.addEventListener('click' , function(){
this.value += "点击\