JavaScript文本框内容改变事件(onchange)

文本框内容改变事件(onchange)


通过改变文本框的内容来触发onchange事件,同时执行被调用的程序。

如下代码,当用户将文本框内的文字改变后,弹出对话框“您刚刚修改了个人简介”。

<!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" onchange="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" onchange="fun()">小明: PHP高级工程师 全栈工程师</textarea> </form> </body> </html>
提交重置代码
章节
笔记
提问
课件
反馈
捐赠

javascript初级教程