>との間のテキストをコピー<して、テキストエリアまたは に貼り付けたいと思いますdiv。たとえば、私が持っている場合
<div><p><div id='1'> Hello my name is </div></p></div>
<div><p><li> Mathieu </div></li></div>
をクリックしてdiv ID=1(DIV にはクラスや ID はありません。これは単なる例です) を選択Hello my name isして自動コピー/貼り付けしたいtextarea. ulしかし、それは、li、pなどのすべてである可能性があります。クリックしたときに とのdiv間のテキストを選択したいだけです。><
私はこれを持っています:
$(document).ready(function() {
$(document).bind("mouseup", function() {
var sel = $.selection('html');
if (sel != '') {
$('#yourTextAreaId').val(sel);
$('#yourDivId').html(sel); // to fill the selection into the body of <div id="yourDivId"></div>
// send the `sel` here
}
});
});