У меня есть HTML-документ, который llokes так:Jquery: запуск кода при выборе текста
<div class="this_can_be_selected">Some text here</div>
<div>No text in the div above is selected</div>
<div class="this_can_be_selected">Some text here</div>
<div>No text in the div above is selected</div>
<div class="this_can_be_selected">Some text here</div>
<div>No text in the div above is selected</div>
Я хочу текст No text in the div above is selected
быть изменен на Some text in the div above is selected
когда, думаю, что, некоторые из текста в DIV выше выбрано :)
jQuery имеет .select() event, что сделало бы это довольно простым в использовании, но кажется, что он работает, когда выделенный текст находится внутри ввода или текстового поля.
Вот код, который я пробовал:
$(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');
}
);
}
);
Ничего не происходит.
Есть ли способ решить эту проблему?
Спасибо! Это сделал трюк! –