jQuery form event select() event
select event
Definition and usage
When the text in the textarea or input element of text type is selected, The select event will occur.
select() method triggers the select event, or specifies the function to be run when the select event occurs.
Let’s take a look at the select() event
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script> </head> <body> <input type="text" value="php 中文網(wǎng)"> <p>php 中文網(wǎng)</p> <script> $('input').select(function(){ $('p').css('color','red'); }) </script> </body> </html>
When the content in the text box is selected, the select() event will be triggered, and then the color of the content of the p tag will be changed