2014年5月13日 星期二

透過jquery定時更換圖片

透過setInterval指令來定時執行某個function。

Source Code:
路口CCTV影像,每隔一秒刷新。
<html>
<head>
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
function show() {
$('#imgCamera').attr('src', 'http://cctv4.kctmc.nat.gov.tw/axis-cgi/jpg/image.cgi?camera=198');
}
$(function () {
setInterval(show, 1000);
});
</script>
</head>
<body>
<img id='imgCamera' style="width:400px" alt="*"/>
</body>
</html>
view raw CCDCamera.html hosted with ❤ by GitHub
DEMO:
參考連結:

沒有留言:

張貼留言