MugenFTW
5/17/2016 - 8:51 AM

Highlight the contents of an element.

Highlight the contents of an element.

function SelectText(element) {
	var doc = document
	, text = doc.getElementById(element)
	, range, selection
	;    
	if (doc.body.createTextRange) {
		range = document.body.createTextRange();
		range.moveToElementText(text);
		range.select();
	} else if (window.getSelection) {
		selection = window.getSelection();        
		range = document.createRange();
		range.selectNodeContents(text);
		selection.removeAllRanges();
		selection.addRange(range);
	}
}

SelectText('#element');