jQuery Select Event Method

jQuery select event method; Through this tutorial, i am going to show you what is jquery select() event method and how to use it with HTML elements.

jQuery Select Event Method

The select event occurs when a text is selected (marked) in the text field or text field. This event is limited to the field and box. When the select occurs, the select() method encloses a function to run.

Syntax jQuery Select Event Method

$(selector).select()  

It triggers a selected event for the selected elements.

$(selector).select(function)  

Parameters of jQuery Select Event Method

ParameterDescription
FunctionIt is an optional parameter. It is used to specify the function to run when the select event is executed.

Example of jQuery Select Event Method

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("input").select(function(){
    alert("Text marked!");
  });
});
</script>
</head>
<body>
<input type="text" value="Hello World">
<p>Select some text inside the input field.</p>
</body>
</html>

Demo of jQuery Select Event Method



Select some text inside the input field.



Recommended jQuery Tutorials

Leave a Comment