Javascript 使HTML按钮在单击时消失,然后在X时间后重新出现?
如何使HTML按钮在单击时消失,然后在2秒钟后重新出现?我找到了一些这样做的方法,但是我需要它来处理我已经有的代码。我怎样才能做到这一点Javascript 使HTML按钮在单击时消失,然后在X时间后重新出现?,javascript,html,button,time,hide,Javascript,Html,Button,Time,Hide,如何使HTML按钮在单击时消失,然后在2秒钟后重新出现?我找到了一些这样做的方法,但是我需要它来处理我已经有的代码。我怎样才能做到这一点 <script language="JavaScript"> function enableTorch(milliSeconds) { ipwajax('enabletorch'); window.setTimeout("ipwajax('disabletorch');",milliSeconds); } </sc
<script language="JavaScript">
function enableTorch(milliSeconds) {
ipwajax('enabletorch');
window.setTimeout("ipwajax('disabletorch');",milliSeconds);
}
</script>
<input type="button" style="font: bold 20px Arial" onclick="enableTorch(1500);" value="LED ON">
功能启用火炬(毫秒){
ipwajax(“使能火炬”);
setTimeout(“ipwajax('disabletorch');”,毫秒);
}
$(文档).ready(函数(){
$(“按钮”)。单击(函数(){
$(“按钮”).hide();
$(“按钮”)。显示(2000);/*2秒时间*/
});
});
点击我
此按钮将隐藏按钮,并在2秒内重新显示
$(文档).ready(函数(){
$(“按钮”)。单击(函数(){
$(“按钮”).hide();
$(“按钮”)。显示(2000);/*2秒时间*/
});
});
点击我
这一个将隐藏按钮,并在2秒内重新显示
给你
检查这个
function enableTorch(milliSeconds) {
ipwajax('enabletorch');
document.getElementById('torch').style.display="none";
setTimeout(function(){ipwajax('disabletorch');document.getElementById('torch').style.display='inline'}, milliSeconds);
}
<input type="button" id = "torch" style="font: bold 20px Arial" onclick="enableTorch(1500);" value="LED ON">
功能启用火炬(毫秒){
ipwajax(“使能火炬”);
document.getElementById('torch').style.display=“无”;
setTimeout(函数(){ipwajax('disabletorch');document.getElementById('torch').style.display='inline'},毫秒);
}
检查此项
function enableTorch(milliSeconds) {
ipwajax('enabletorch');
document.getElementById('torch').style.display="none";
setTimeout(function(){ipwajax('disabletorch');document.getElementById('torch').style.display='inline'}, milliSeconds);
}
<input type="button" id = "torch" style="font: bold 20px Arial" onclick="enableTorch(1500);" value="LED ON">
功能启用火炬(毫秒){
ipwajax(“使能火炬”);
document.getElementById('torch').style.display=“无”;
setTimeout(函数(){ipwajax('disabletorch');document.getElementById('torch').style.display='inline'},毫秒);
}
您可以更改此行的毫秒数$(“按钮”).show(2000)代码>但是我如何使用我已有的按钮来完成呢?我发布了我已经在使用的代码。请帮忙。感谢您在代码中发布的js是否可以被其他js替换??或者您是否坚决不使用另一个js?您可以在这一行$(“button”).show(2000)更改毫秒数代码>但是我如何使用我已有的按钮来完成呢?我发布了我已经在使用的代码。请帮忙。感谢您在代码中发布的js是否可以被其他js替换??或者你确定不使用另一个js吗?实际上按钮可以工作,尿布/看起来很好,但LED现在可以工作了??哪个LED?是否要像在代码中一样调用函数ipwajax()。我会将该呼叫添加到我的代码Yes ipwajax(“enabletorch”)打开我的android手机LED,然后LED也必须在2秒后ipwajax(“disabletorch”)自动关闭。所以我试图让按钮在LED亮起时消失,并在LED自动亮起2秒或3秒后将按钮转到收割机。请检查我上面修改的代码。如果您仍然有问题,请报告两个似乎都有效:-)您是伴郎!我不可能在自己的lol中找到答案。实际上按钮可以工作,尿布/看起来很好,但是LED现在可以工作了??哪个LED?是否要像在代码中一样调用函数ipwajax()。我会将该呼叫添加到我的代码Yes ipwajax(“enabletorch”)打开我的android手机LED,然后LED也必须在2秒后ipwajax(“disabletorch”)自动关闭。所以我试图让按钮在LED亮起时消失,并在LED自动亮起2秒或3秒后将按钮转到收割机。请检查我上面修改的代码。如果您仍然有问题,请报告两个似乎都有效:-)您是伴郎!我不可能靠自己解决这个问题,哈哈。欢迎来到这里。你可能会接受最有帮助的答案。欢迎访问SO。你可以接受最有用的答案。
function enableTorch(milliSeconds) {
ipwajax('enabletorch');
document.getElementById('torch').style.display="none";
setTimeout(function(){ipwajax('disabletorch');document.getElementById('torch').style.display='inline'}, milliSeconds);
}
<input type="button" id = "torch" style="font: bold 20px Arial" onclick="enableTorch(1500);" value="LED ON">
$(document).ready(function(){
$("button").click(function(){
$(this).hide().show(2000);
});
});