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

どうぞhttp://jsfiddle.net/4eCrQ/

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