0

如何使 HTML 按钮在单击时消失,然后在 2 秒后重新出现?我找到了一些方法,但我需要它来处理我已经拥有的代码。我怎样才能做到这一点?

<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">
4

4 回答 4

1
<!--
$("p").hide()
Demonstrates the jQuery hide() method, hiding all <p> elements.
-->
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("button").hide();
    $("button").show(2000);/*2 sec time*/
  });
});
</script>
</head>

<body>

<button>Click me</button>
</body>
</html>

这个将隐藏按钮并在 2 秒内重新显示

于 2013-02-08T05:42:30.737 回答
1

检查这个

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">
于 2013-02-08T05:51:56.793 回答
1
$(document).ready(function(){
  $("button").click(function(){
    $(this).hide().show(2000);
  });
});
于 2013-02-08T05:55:14.647 回答
0

给你http://jsfiddle.net/4eCrQ/

$('.first').on('click', function() {
    $('.second').hide();
    setTimeout(function() {
        $('.second').show();
    }, 2000);
});
于 2013-02-08T05:46:37.177 回答