select() method

select() method

The select event occurs when a text is selected (marked) in a text area or a text field. The select() method triggers the select event or attaches a function to run when a select event occurs.


Syntex:

$(selector).select()


Example :-


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("input").select(function(){
        alert("Text selected from textbox !");
    });
});
</script>
</head>
<body>

<input type="text" value="Hello 'Nitin Kumar  chauhan'" style="height:30px;width:200px">

<p>Select some text from textbox .</p>

</body>
</html>