문제

I have the code below that turns ON my phones LED flash every time the button is clicked, but I also need the LED to turn OFF automatically after 3 seconds. Not sure how to do it, please help.

input type="button" onclick="ipwajax('enabletorch')" value="Turn on LED"

도움이 되었습니까?

해결책

Assuming ipwajax('enabletorch') enables the LED, and ipwajax('disabletorch') disables it, you would want something like

<script language="JavaScript">

  function enableTorch(milliSeconds) {
    ipwajax('enabletorch');
    window.setTimeout("ipwajax('disabletorch');",milliSeconds);
  }

</script>

<input type="button" onclick="enableTorch(3000);" value="Turn on LED">
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top