JavaScript content selection event (onselect)

Content selection event (onselect)


Select event, when the text in the text box or text field is selected, the onselect event is triggered. The program called at the same time will be executed.

In the following example, when text is selected, a warning dialog box for prohibiting assignment pops up

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script>
            function fun(){
                window.alert("这是个人简介,禁止复制")
            } 
        </script>
    </head>
    <body>
        <form>
            个性介绍:<br/><textarea name=" introduction" cols="30" rows="4" onselect="fun()">小明:
            PHP高级工程师
            全栈工程师</textarea>
        </form>
    </body>
</html>


Continuing Learning
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script> function fun(){ window.alert("这是个人简介,禁止复制") } </script> </head> <body> <form> 个性介绍:<br/><textarea name=" introduction" cols="30" rows="4" onselect="fun()">小明: PHP高级工程师 全栈工程师</textarea> </form> </body> </html>
submitReset Code