我必須執行一個動畫,其中切換兩個圖像。圖片ID是image_anim
。getElementById給出錯誤
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Chill</title>
<link rel="stylesheet" type="text/css" href="../css/Start_Page_css.css"/>
<script src="../Java_Script/button_click.js"></script>
<script type="text/javascript">
var boxOne = document.getElementsById("image_anim");
setTimeout(function()
{
for (var i=0;i<4;i++) {
setTimeout(function()
{
setTimeout(function()
{
boxOne.src="../Images/p1.png";
},250);
setTimeout(function()
{
boxOne.src="../Images/p2.png";
},250);
},500);
};
}, 3000);</script>
</head>
<body ng-app="app">
<div class="container" >
<div class="table_set_up_conn">
<div class="set_up_conn">SETTING UP YOUR CONNECTION</div>
</div>
<div class="table_image_anim">
<img id="#image_anim" src="../Images/p1.png"/>
</div>
<div class="grey_layout_anim">
<div class="bold_write"><br>Now let's connect to your Clipsal Hub</div>
<div class="norm_write">1. Go to the Wi-Fi settings on your phone<br><br>2. Connect to the Clipsal Hub network<br><br>3. Return to this app when you're done<br><br></div>
</div>
<div class="table_centre_image">
<img id="#centre_image" src="../Images/p2.png"/>
</div>
</div>
</body>
</html>
的錯誤是
Uncaught TypeError: undefined is not a function .
Function is :getElementsById
getElementsById它的getElementById – 2014-11-06 11:09:33
簡單,沒有getElementsById方法 – 2014-11-06 11:09:33
@Pallavi我投票決定關閉的問題,因爲它沒有進一步相關的任何人你解決你的後自己的代碼。你怎麼自己發現這些錯誤?在您的瀏覽器中,打開[Web控制檯](http://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers)。通常它會向您顯示出錯的地方(包括線路)。 – Boldewyn 2014-11-06 11:12:20