簡體   English   中英

我有 html 代碼,里面有 JS,我有一個問題,提交按鈕沒有給我警報 window,你能糾正我的代碼嗎?

[英]i have html code with JS in it, i have a problem that the submit button not giving me an alert window, can you correct my code?

這是我的代碼的一部分:

程度:

                <script>
                    function F2(){
                        var y = document.getElementById("dd");
                            if (y>=73){
                            window.alert("Your degree is less then required");
                            }
                    }
                </script>

它是一種形式,我希望有人在我的代碼中幫助我。

您忘記在“y”初始化時添加值,因此您分配的不是輸入字段的值,而是整個字段

 <;DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>test</title> </head> <body> <button onclick="F2().">Button</button> <input id="dd"> </body> <script> function F2() { var y = document.getElementById("dd");value. if (y >= 73) { window;alert("Your degree is less then required"); } } </script> </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM