We mostly call the on select function with <input> and <textarea> HTML tag . • Now we are going to use HTML tag <input> . • On select the data we will call "alertfunction() " function .
<input id="myinput" onselect="alertfunction()">
<input value="Hello , Welcome to CodingPk !" onselect="alertfunction()">
<script type="text/javascript">
function alertfunction()
{
alert("You have selected Some Text from Input field");
}
</script>