jQuery : get html source of selected text in div
<p>I want to get HTML source of select text in div and alert that.</p>

<p>This is my code:</p>

<pre><code>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);
    });
</code></pre>

<p><a href="http://stackoverflow.com/questions/5669448/get-selected-texts-html-in-div">Source</a></p>

<p>But that return text plain.</p>

<p>Is there any way?</p>

<p>Thanks for any help.</p>
