I want this text inside
The solution change based on the current browser, with older version of jQuery I use Demo: http://jsfiddle.net/IrvinDominin/bKPcX/
$.browser
, but now is deleted; to check it's IE and use the correct code check if document.body.createTextRange
exist like:$(document).ready(function () {
selectText('sample_div');
});
function selectText(element) {
var text = document.getElementById(element);
if (document.body.createTextRange) {
var range = document.body.createTextRange();
range.moveToElementText(text);
range.select();
} else {
var selection = window.getSelection();
var range = document.createRange();
range.selectNodeContents(text);
selection.removeAllRanges();
selection.addRange(range);
}
}