首页> 基础笔记 >JS/JQ基础学习 >事件 事件
JavaScript-选中事件和复制事件
作者:小萝卜 2023-03-22 【 javascript 】 浏览 711
简介JavaScript-选中事件和复制事件onselect,oncopy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>onselect</title>
</head>
<body>
<textarea name="" id="intro" cols="30" rows="10"></textarea>
<script type="text/javascript">
var intro = document.getElementById('intro');
// 下面那两个事件 只能在input和textarea元素中使用
//绑定选择事件
intro.onselect = function(){
// alert('i am selected');
}
intro.oncopy = function(){//copy复制
console.log('我被复制了');//asdfghjasdfghj asdfghjasdfghjasdfghj
return false;
}
</script>
</body>
</html>
很赞哦! (0)