<div onselect="message()"></div>
怎么运行不了
怎么运行不了
2018-07-13
onselect 是放在输入框里面的。而在普通文本上面的检测,一般使用onmouseup就行了
<p onmouseup="getText()">aaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
<script type="text/javascript">function getText(){ var txt=""; if(document.selection){ txt = document.selection.createRange().text; }else{ txt = window.getSelection().toString(); } console.log(txt);}</script>
举报