如何在按下按钮后添加按钮。它会在5秒之后将我重定向到一边? 我尝试了很多不同的东西,但它不适合我...... 它需要是一个onClick函数(javascript)。
HTML:
<html>
<head>
<style type="text/css">
#save_first { display: none; }
#save_second { display: none; }
#save_third { display: none; }
</style>
<script type="text/javascript" src="http://mctheblitz.com/servers/js/jquery.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
</head>
<body>
<input type="button" value="Save" onClick="save();"/>
<div id="save_first"></div><div id="save_second"></div>
<?php
</body>
</html>
javascipt的:
function save() {
$('#save_first').html('Validating...');
$('#save_first').fadeIn(1);
$('#save_first').delay(2000);
$('#save_first').fadeOut(300);
$('#save_second').html('Successfully log in!');
$('#save_second').hide();
$('#save_second').delay(2350);
$('#save_second').fadeIn(0);
}
Tnx寻求帮助!
答案 0 :(得分:0)
这应该会将您重定向到另一个网站:
window.location =“http://www.yoururl.com”;
答案 1 :(得分:0)
你可以基本上只使用setInterval(code,millisec)创建一个5000的函数。并用你有的函数替换代码。
<html>
<body>
<input type="text" id="clock">
<script language=javascript>
function fiveseconds() {
setInterval(function(){clock()},5000);
}
function clock() {
alert("pow");
}
</script>
<button onclick="fiveseconds()">Stop</button>
</body>
</html>
答案 2 :(得分:0)
看起来你正在使用jQuery。你可以这样做:
$('#id-of-button').click(function() {
setTimeout(function () { location.href='http://url.tld'; }, 5000);
$(this).unbind();
});
<强>演示强>