尝试做一个测验页面,我需要在文本区域中写入最少字符数后显示“提交”按钮。这是我尝试过但无法使其发挥作用的方法。
<textarea name="tweet" id="textbox" rows="13" cols="70" placeholder="" maxlength="250"></textarea><br> <span id="char_count">0/250</span> <script> let textArea = document.getElementById("textbox"); let characterCounter = document.getElementById("char_count"); const minNumOfChars = 0; const maxNumOfChars = 250; var text = document.getElementById("buton"); const countCharacters = () => { let numOfEnteredChars = textArea.value.length; let counter = minNumOfChars + numOfEnteredChars; characterCounter.textContent = counter + "/250"; }; textArea.addEventListener("input", countCharacters); if (counter > 100 ) { text.style.display = "block"; } else { } </script> <br><br><br> <div> <button class="NextStep" id="buton" style="display:none" onclick="NextStep()">Finalizare Curs</button> </div> <script> function NextStep() { location.href =("Cursuri.html") } </script>
您的代码具有工作所需的所有必要部分,但您已经像毕加索的画一样重新构建了它!在正确的位置进行一些剪切-复制-粘贴,就可以了!