有人可以解釋,這個代碼有什麼問題。一旦在Web瀏覽器中打開了html,圖像就不會在間隔時間內動態更改。JQuery - Dynamic Img Src Attr變更
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Blinking Text</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var x;
setInterval(function() {
if(x == 0) {
$('blinking').attr('src', "http://www.example.com/images/banner1.png");
x = 1;
} else {
if(x = 1) {
$('blinking').attr('src', "http://www.example.com/images/banner2.png");
x = 0;
}
}
}, 750);
});
</script>
</head>
<body>
<div class="blinking"><img src="http://www.example.com/images/banner1.png"></img></div>
</table>
</body>
</html>
- 在此先感謝