I am trying to highlight the text inside a div / span automatically when the page loads.
I am able to highlight text in a read-only textbox but, the text inside a div / span, is not working.
I am using typescript in my application.
Fiddler: http://jsfiddle.net/5zWad/75/
HTML:
<input type="text" readonly="readonly" value="ABC" />
<div>
<span>
this is a span
</span>
</div>
<div>
this is a div
</div>
JS Inside a typescript method,
//WORKING
$('input').select();
//NOT WORKING
$('span').select();
//NOT WORKING
$('div').select();
I looking for a suggestion that works with typescript.
Any suggestion / direction will be greatly appreciated. Thanks.
Edit:
I tried the suggestion provided by "Get Off My Lawn" but, typescript is not recognizing the createTextRange() and showing error.