<input type="text"> event: <span id="result"></span>
<script>
var input = document.body.children[0];
input.oncopy = function(e) {
debugger
e = e || event;
// document.getElementById('result').innerHTML = e.type +' '+input.value;
// return false;
}
我希望在复制时获取文字。这可能吗?
答案 0 :(得分:2)
试试:
input.oncopy = function(e) {
var value = this.value.substring(this.selectionStart, this.selectionEnd);
}