为此难以找到插件的原因并不是它不是非常"jQuery".我的意思是jQuery插件通常在jQuery对象上运行,并且选择与任何元素无关.
编辑:我错过了你在你的问题中发布此链接的事实,但我将保留下面的完整性,因为我的版本格式更好(但在其他方面相同).:)
<script language=javascript>
function getSelText() {
var txt = '';
if (window.getSelection) {
txt = window.getSelection();
} else if (document.getSelection) {
txt = document.getSelection();
} else if (document.selection) {
txt = document.selection.createRange().text;
} else return;
document.aform.selectedtext.value = txt;
}
</script>
<input type="button" value="Get selection" onmousedown="getSelText()">
<form name=aform >
<textarea name="selectedtext" rows="5" cols="20"></textarea>
</form>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7027 次 |
| 最近记录: |