I have a code for on click select all text. But unfortunately not working on IE. can anyone give the fix for this.
Need a fix for all browser compatable.
This script is working on below IE 9.0. Not working for IE 10 and above. so kindly give the solution.
Code:
<!DOCTYPE html>
<html>
<head>
<title>autoresizing textarea</title>
<style type="text/css">
#divid {
display:inline-block;
border: solid 1px #000;
min-height: 20px;
width: 300px;
}
</style>
<script type="text/javascript">
function selectText(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
}
}
</script>
</head>
<body>
<div id="divid" onclick="selectText('divid')">Lorem Ipsum is simply dummy text of the printing and typesetting industry. </div>
<div>
Lorem Ipsum is simply dummy text </div>
</body>
</html>