提交表单后如何显示 Div 和隐藏表单?香港专业教育学院试过 jquery 但它不工作。帮我?这是代码:
website body {
background-color: black; color: green; }#theirname { color:red; font-size: 6.0em; margin:auto; text-align:center; display:none; } #hellos { color:yellow; font-size:6.5em; margin-top:auto; text-align:left; display:none; } #thanks { color:yellow; font-size:4.3em; margin-right:20px; text-align:right; display:none; } #hello { border-style:groove; border-color: yellow; margin:auto; text-align:center; width:300px; } marquee { color:yellow; font-size:30px; } form { text-align:center; margin:auto; margin-top:120px; } </style> <script> function handler() { var div = document.getElementById('theirname'); var form = document.getElementById('fore'); div.innerHTML = document.getElementById('textbox').value; return false; } $(document).ready(function(){ $("#Fore").submit(function(e){ $("#fore").hide(slow); $("#hellos").show(3000); $("#theirname").show(3030); $("#thanks").show(4000); }); }); </script> </head> <body> <div id="hello">Welcome to here :D</div> <marquee behavior="scroll" scroll="left" bgcolor="red" onClick="">ill update this soon...</marquee> <div id="hellos">Hello,</div> <div id="theirname"></div> <div id="thanks">thank you for coming!</div> <form id="Fore" action="submit" method="post" onSubmit="return handler();"> Your name: <input id="textbox" type="text" name="fname" size="20" /> <input type="submit" value="post" /> </form> </body> </html>
这是让你明白我的意思。 jfiddle
最佳答案
您的 javascript 有错误:
改变
$("#fore").hide(slow);
到
$("#Fore").hide('slow'); // Your id is Fore and not fore
关于jquery - 提交表单后如何显示 Div 并隐藏表单?我试过 jquery 但它不起作用。帮我?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22049493/