Prev Demo
jQuery
>
.Select() - Select Text Or Attach Select Event
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> </head> <body> <div id="divSelect" style="cursor: pointer;">Click here to select below text</div> <textarea id="txtAreaSelect" cols="20" rows="5">Try selecting this text</textarea> <script> // first function $("#txtAreaSelect").select(function () { alert("you are trying to select"); }); // second function $("#divSelect").click(function () { $("#txtAreaSelect").select(); }); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output