A
afrinspray
Is there a way to get the selected text inside a div, or other element?
Mike
Mike
I didn't want to set the text of an element, but your function gave me
the window.getSelection() function to lead me in the right direction.
This function doesn't work for me in IE, so I made this function
below... it seems to work alright.
function getSelectedText() {
if(window.getSelection) {
return window.getSelection();
}
else if(document.selection.createRange().text) {
return document.selection.createRange().text;
}
return '';
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.