Jquery 显示/隐藏设定期间的div
在我的表单中,我在单击时隐藏提交按钮,并显示一个div,显示Jquery 显示/隐藏设定期间的div,jquery,html,forms,Jquery,Html,Forms,在我的表单中,我在单击时隐藏提交按钮,并显示一个div,显示提交… 这是非常基本的。看 jQuery代码是: jQuery("#subnewtopicform").submit(function(e) { // Hide button by button ID jQuery("#subnewtopic").hide(); // Show hidden div jQuery("#submitted").show(); }); 和HTML: <form a
提交…
这是非常基本的。看
jQuery代码是:
jQuery("#subnewtopicform").submit(function(e) {
// Hide button by button ID
jQuery("#subnewtopic").hide();
// Show hidden div
jQuery("#submitted").show();
});
和HTML:
<form action="" method="post" id="subnewtopicform" />
Title:
<input type="text" name="title" /><br/>
<input type="submit" value="Submit Topic" class="button-primary" name="subnewtopic" id="subnewtopic" />
</form>
<div id="submitted" style="display:none">Submitting...</div>
标题:
提交。。。
我的问题是,我如何使它在20秒后再次显示#subnewtopic
,并隐藏#subnewtopic
(回到最初的状态)?您可以使用它来实现这一点
完整的javascript可以是:
jQuery("#subnewtopicform").submit(function(e) {
// Hide button by button ID
jQuery("#subnewtopic").hide();
// Show hidden div
jQuery("#submitted").show();
setTimeout(function() {
jQuery("#subnewtopic").show();
jQuery("#submitted").hide();
},20000);
});
你可以用它来实现这一点
完整的javascript可以是:
jQuery("#subnewtopicform").submit(function(e) {
// Hide button by button ID
jQuery("#subnewtopic").hide();
// Show hidden div
jQuery("#submitted").show();
setTimeout(function() {
jQuery("#subnewtopic").show();
jQuery("#submitted").hide();
},20000);
});
您可以使用
setTimeout
在设置的延迟后运行代码块:
$("#subnewtopicform").submit(function (e) {
$("#subnewtopic").hide();
$("#submitted").show();
setTimeout(function() {
$("#subnewtopic").show();
$("#submitted").hide();
}, 20000);
});
您可以使用
设置超时
在设置延迟后运行代码块:
$("#subnewtopicform").submit(function (e) {
$("#subnewtopic").hide();
$("#submitted").show();
setTimeout(function() {
$("#subnewtopic").show();
$("#submitted").hide();
}, 20000);
});
该JSFIDLE与我发布的相同。该JSFIDLE与我发布的相同。