Ron*_*nie 1 html javascript css jquery
假设我在页面中有两个DIVS.#newsdiv和#impdiv分别.
<div id="news">
Apple is facing a lawsuit for not telling users about the amount of memory required by an upgrade its flagship operating system.
</div>
<div id="imp">
<!-- Empty -->
</div>
Run Code Online (Sandbox Code Playgroud)
现在我的要求是,如果我从整个句子中仅选择"Apple",那么所选部分将被复制并粘贴到div中#imp.如果复制,则会附加其他部分.
你能做这样的事吗?
$( document ).ready(function() {
$('#news').mouseup(function (e){
text = window.getSelection().toString();
$('#imp').append(text);
});
});
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
JS Bin:http://jsbin.com/xabije/edit?html, js,output
| 归档时间: |
|
| 查看次数: |
3440 次 |
| 最近记录: |