Jquery: run code when text is selected
<p>I have a HTML document which llokes like this:</p>

<pre><code>&lt;div class="this_can_be_selected"&gt;Some text here&lt;/div&gt;
&lt;div&gt;No text in the div above is selected&lt;/div&gt;

&lt;div class="this_can_be_selected"&gt;Some text here&lt;/div&gt;
&lt;div&gt;No text in the div above is selected&lt;/div&gt;

&lt;div class="this_can_be_selected"&gt;Some text here&lt;/div&gt;
&lt;div&gt;No text in the div above is selected&lt;/div&gt;
</code></pre>

<p>I want text <code>No text in the div above is selected</code> to be changed to <code>Some text in the div above is selected</code> when, guess what, some of the text in the div above is selected :)</p>

<p>jQuery has a <a href="http://api.jquery.com/select/" rel="nofollow">.select() event</a>, that would make this rather easy to do, but seems, that it works when selected text is inside input or textarea.</p>

<p>Here is a code that I've tried:</p>

<pre><code>$(document).ready(function()
    {

        //Some text inside div is selected
        $('DIV.this_can_be_selected').select
        (
            function()
            {
                alert('Something is selected!');
                $(this).next().html('Some text in the div above is selected');
            }
        );

    }
);
</code></pre>

<p>Nothing is happening.</p>

<p>Is there a way to solve this problem?</p>
