jQuery Tutorial Tutorials - jQuery .select() method

jQuery .select() method

The .select() method in jQuery is used to bind an event handler to the select event on the <input type="text"> or <textarea> elements.

It is also used to trigger select event on an element.

jQuery .select() method Syntax

.select()
.select(handler)
.select(eventData,handler)
Parameter Type Description
handler Function A function to execute when the select is triggered on the matched element.
eventData Anything Additional data passed to the event handler.

jQuery .select() method Example

When user make a text selection inside a <inpt type="text"> or <textarea>, a select event will be triggered and sent to the box element.

example

Trigger select event on all inputs.
It will select the text inside the last element that get select event.

$("input").select();

example

HTML

<p><input type="text" name="username" value="Select some text inside me"></p>
$( "input" ).select(function() {
    console.log("Something was selected inside inputbox "+$(this).attr("name"));
});

Try now

Date:2019-08-29 20:07:19 From:www.Lautturi.com author:Lautturi