Hello,
I have a div in which I have written values fetched from an ajax call.
I want, when double click on any word in that div , alert that word.
I refered http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/479879/how-to-detect-clicked-word-in-textarea-with-right-click-and-show-menu-items and well some stackoverflow.
but did not get answer.
code is as below FYI.
$("#other_skill_name").keypress(function()
{
var input = document.getElementById('other_skill_name');
var div = document.getElementById('other_skill_from_DB');
var ajax_output = other_skills_from_DB(input.value); // this is my ajax call which fetch values
div.innerHTML=ajax_output; // by this, put return values in div
document.getElementById('other_skill_from_DB').ondblclick = function ()
{
var sel = (document.selection && document.selection.createRange().text) ||
(window.getSelection && window.getSelection().toString());
alert(sel); // this gives me empty alert
};
});