2014-02-26 39 views
1

如何在表单提交后显示Div并隐藏表单?香港专业教育学院试图jQuery的,但它没有奏效。帮我?这里是代码:如何在表单提交后显示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

+1

+1为选取框... –

+0

+50为选取框... – Kody

+0

你什么意思? lol – Mrawesome4ever

回答

1

你在你的JavaScript中的错误:

变化

$("#fore").hide(slow); 

$("#Fore").hide('slow'); // Your id is Fore and not fore 
+1

+1已更新jsFiddle:http://jsfiddle.net/P2knf/9/ –

+0

我刚刚更新了我的代码,并且还在[jsfiddle](http://jsfiddle.net/mrawesome4ever/P2knf/10/)上,但它仍然不起作用。 – Mrawesome4ever

+0

删除

相关问题