我已经使用javascript消失了我的表单,但现在我想在表单显示为none时显示一行文本,我不确定javascript的正确布尔运算符是什么。
<script>
function Enter() {
survey.style.display = "none";
if (survey==="none"){
thank.style.display = "inline";
}
else {
thank.style.display = "none";
}
}
</script>
<div id="right">
<div id="thank" style=" display: none">
Thank you, your message has been sent.
</div>
<form name="survey" id="survey" action="" method="post">
<input type="submit" value="Contact Us!" onclick="Enter()"/>
</form>
</div>
错误讯息:
“message”:“SyntaxError:expect expression,got'&lt;'”,“filename”: “https://stacksnippets.net/js”,“lineno”:13,“colno”:28
答案 0 :(得分:0)
如果我理解正确,
你想要一行默认的tekst:“display:none” 所以:
<p id="MyTekst" style="display: none">My line of tekst</p>
将其与您的脚本结合使用:
<script>
function Enter() {
survey.style.display = "none";
if (survey==="none"){
thank.style.display = "inline";
document.getElementById("MyTekst").style.display = "block";
}
else {
thank.style.display = "none";
}
}
</script>
告诉我们是否有帮助
答案 1 :(得分:0)
使用它:
<script>
function Enter() {
survey.style.display = "none";
if (survey.style.display==="none"){
thank.style.display = "inline";
}
}
</script>