JavaScript内容选中事件(onselect)

内容选中事件(onselect)


选中事件,当文本框或者文本域中的文字被选中时,触发onselect事件,同时调用的程序就会被执行。

如下实例,当选择文字后,弹出禁止赋值警告对话框

<!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>


继续学习
||
<!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>
提交重置代码
章节
笔记
提问
课件
反馈
捐赠

javascript初级教程