<html>
<body>
<form> Select text: <input type="text" value="Hello world!" onselect="alert('You have selected some of the text.')"> <br /><br /> Select text: <textarea cols="20" rows="5" onselect="alert('You have selected some of the text.')">
Hello worl!</textarea> </form>
</body>
</html>In this code is select text after show alert message in JavaScript.
