Jump to content

[SOLVED] Selecting Text In A Textarea


The Little Guy

Recommended Posts

function getSelText(){
var mbox = document.getElementById('message');
if (window.selection) { // for IE
	alert(document.selection.createRange().text);
} else if (typeof mbox.selectionStart != 'undefined') { // for FF, Opera etc...
	alert(mbox.value.substring(mbox.selectionStart, mbox.selectionEnd));
} else {
	alert('Could not find selection');
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.