javascriptで指定秒数ごとに関数を実行したい
Q&A
Closed
解決したいこと
javascriptで指定秒数ごとに関数を実行したいのですが、指定した秒数ごとに呼び出されません。
該当するソースコード
```<!DOCTYPE html>
<html>
<head>
<title>IntervalごとのAlert</title>
</head>
<body>
<script>
// 引数で受け取った秒数ごとにalertを表示
function showAlertAtInterval(seconds) {
alert("hello world");
}
// ここに秒数を指定して関数を呼び出す
var intervalInSeconds = 5;
setInterval(function() {
showAlertAtInterval(intervalInSeconds);
}, intervalInSeconds);
</script>
</body>
</html>
0 likes