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>
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!