2012-12-15 4 views
0

이 내 코드는 IE9 크롬 파이어 폭스하지만 IE7에서 일하고 및 Internet Explorer 8은 :(가 작동하지 IE7 IE8

HTML 코드

<ul class="controls"> 
<li style="font-size: 10px; font-weight: bold; left: 310px; position: absolute; text-transform: uppercase; top: -102px;"> 
<a id="pp" href="#" title="" onclick="playPause()"><img src="../css/play.png"></a> 
</li> 
</ul> 

에게 작동하지 않는 자바 스크립트 코드

var inter; 
function playPause(){ 
if($('.controls li #pp').html() == '<img src="../css/play.png">'){ 
inter = setInterval(function() { 
changeBannerImg(num,1); 
}, 4600); 
document.getElementById('pp').html = '<img src="../css/pause.png">'; 
} 
else if($('.controls li #pp').html() == '<img src="../css/pause.png">'){ 
clearInterval(inter); 
document.getElementById('pp').html = '<img src="../css/play.png">'; 
} 
} 
function stopAni(){ 
clearInterval(inter); 
document.getElementById('pp').html = '<img src="../css/play.png">'; 
} 
+1

당신은 점점 어떤 오류? – ajtrichards

+2

'document.getElementById ('pp') .html ='? 이게 뭐야? –

+0

$ (selector) .html()의 comparsion이 올바르지 않을 수도 있습니다. –

답변

1

이게 작동합니다.

HTML

<ul class="controls">   
    <li style="font-size: 10px; font-weight: bold; left: 310px; position: absolute; text-transform: uppercase; top: -102px;"> 
  <a id="pp" href="#" title=""><img src="../css/play.png"></a> 
  </li> 
</ul> 

JS

$(function() { 
    var img = $('.controls li #pp img'); 

    function playPause() { 
        if (img.attr('src').match(/play\.png$/)) { 
            inter = setInterval(function() { 
                changeBannerImg(num, 1); 
            }, 4600); 
            img.attr('src', "../css/pause.png"); 
        } else if (img.attr('src').match(/pause.png$/)) { 
            clearInterval(inter); 
            img.attr('src', "../css/play.png"); 
        } 
     return false; 
    } 

    function stopAni() { 
        clearInterval(inter); 
        img.attr('src', "../css/play.png"); 
    } 
    img.parent().click(playPause); 
// other code here 


});​ 
+0

고맙습니다. –

관련 문제