div内の選択したテキストのHTMLソースを取得し、それを警告したいと思います。
これは私のコードです:
if (!window.x) {
x = {};
}
x.Selector = {};
x.Selector.getSelected = function() {
var t = '';
if (window.getSelection) {
t = window.getSelection();
} else if (document.getSelection) {
t = document.getSelection();
} else if (document.selection) {
t = document.selection.createRange().text;
}
return t;
}
$(function() {
$(document).bind("mouseup", function() {
var mytext = x.Selector.getSelected();
alert(mytext);
});
しかし、それはプレーンテキストを返します。
方法はありますか?
助けてくれてありがとう。