2016-03-22 5 views
0

誰かが私に助言をくれたのですが、javascript/jqueryが正常に動作しない理由を教えてください。最初の2つのリンクが働いて回転アイコンを示していますが、私はそれが仕事をしたい第3のリンクが正しく動作しません...私のホームページではなく、どこにでも回転していますが、私のホームページにはありません

http://cdubach.com/inc/test.php 
    Where I took all content within the jsfiddle I created and tested it on the server. 

    https://jsfiddle.net/752tfqyu/17/ 
    JSfiddle I used to created the content that works. 

    http://cdubach.com/pages/home/index.php 
    Where I have an issue, the icon will not rotate. Cannot seem to find the issue. 

    Main Javascript/Jquery used to rotate the icon 

    /* [(START)Rotate Icon:SCroll Down] ----------------> */ 

    $(document).ready(function(){ 
     $(window).scroll(function() { 
     if ($(window).scrollTop() < 300) { 
     $("#rotate").css({ 
      "top": $(window).scrollTop() + "px"}); 
      } 
     }); 
    }); 
    /* [(END)Rotate Icon:SCroll Down] ------------------> */ 

    var looper; 
    var degrees = 0; 
    function rotateAnimation(el, speed) { 
    var elem = document.getElementById(el); 
    if (navigator.userAgent.match("Chrome")){ 
    elem.style.webkitTransform = "\"rotate(" + degrees + "deg)\""; 
    } else { 
    elem.style.transform = "\"rotate(" + degrees + "deg)\""; 
    } 

    looper = setTimeout('rotateAnimation(\''+el+'\','+speed+')',speed); 
    degrees++; 
    if (degrees > 359) { 
    degrees= 1; 
    } 

    } 
+1

あなたは自分のホームページ上のJavaScriptエラーの全体のスルーを取得します。エラーが発生すると、スクリプトの他の部分は実行できなくなります。他の詳細を見ることなく、それらのエラーを修復するだけで必要な解決策が得られるかもしれません。 – VoteyDisciple

+0

これらのエラーの1つは時計のように累積します。 – ChiefTwoPencils

答えて

0

私はあなたのフィドルとあなたが思われるもの掲示し、見つかったコードの間にいくつかの比較をしました問題である。

あなたのWebKitTransFormで二重引用符をエスケープしようとしているようですが、それは完全にはわかりませんが、それを元に戻すことで動作させることができます。それに

Here's codepen作業:

var looper; 
var degrees = 0; 
function rotateAnimation(el, speed) { 
    var elem = document.getElementById(el); 
    if (navigator.userAgent.match("Chrome")){ 
    elem.style.WebkitTransform = "rotate("+degrees+"deg)"; 
    } else { 
    elem.style.transform = "rotate("+degrees+"deg)"; 
    } 
    looper = setTimeout('rotateAnimation(\''+el+'\','+speed+')',speed); 
    degrees++; 
    if (degrees > 359) { 
    degrees= 1; 
    } 

} 
関連する問題