2011-06-21 8 views
0

jQueryホバー効果に問題があります。基本的にChromeとIEのバージョンでは完全に機能していますが、Firefoxでは動作しません。jQuery Hover - Firefoxで動作していない

非常にシンプルなjQueryコードですが、なぜ動作しないのかわかりません。 jQueryをデバッグするための優れたツールはありますか?

http://www.ryansammut.com/jQueryHover.html

+1

この質問には、サイトのコードを追加してください。 – JohnP

+1

これを追加してください$( '#shopNowButton') – K6t

+0

@ K6t - ありがとうございました。 jQueryのデバッグにはどのツールを使用しますか? –

答えて

2

あなたのセレクタに

$(document).ready(function(){ 
    $(".contactButton").hover(function() { 
     $(contactButtonMenu <---).attr("src","images/contactButtonHover.png"); 
      }, function() { 
     $(contactButtonMenu <----).attr("src","images/contactButton.png"); 
    }); 
}); 

$(document).ready(function(){ 
    $(".contactButton").hover(function() { 
     $(shopNowButton <----).attr("src","images/shopNow.png"); 
      }, function() { 
     $(shopNowButton <----).attr("src","images/shopNowHover.png"); 
    }); 
}); 
+0

contactButtonMenuの代わりに '#contactButtonMenu'を追加するだけで動作します。ありがとう:) –

+0

@RyanSammut cool :) btw、JSをデバッグするためにfirebugを使用できます。それはイベントが正常に呼ばれていることを示します。セレクタが何も返さなかったということだけです。 – JohnP

0

を '#' が欠けているあなたは一つだけdocument.readyを必要としています。 また、ホバーは彼が変更しなければならない項目(contactButtonMenuとshopNowbutton)を見つけることができませんでした。次のことを試してください。

$(document).ready(function(){ 
    $(".contactButton").hover(function() { 
     $(this).attr("src","images/contactButtonHover.png"); 
      }, function() { 
     $(this).attr("src","images/contactButton.png"); 
    }); 

    $(".contactButton").hover(function() { 
     $(this).attr("src","images/shopNow.png"); 
      }, function() { 
     $(this).attr("src","images/shopNowHover.png"); 
    }); 
}); 




<img id="contactButtonMenu" src="images/contactButton.png" alt"Contact Button" class="contactButton" /> 

あなたのALTタグでも不正な形式である、のように変更します。前の行でalt="Contact Button"

+0

ホバリングはいいです、あなたが私に与えた効果は、私が欲しいものではありませんが、alt問題を発見してくれてありがとう。私が必要とするものは、Contact Hoverにあるので、Shop NowのHoverはオフになります。 –

0

、それを置き換える

alt"Contact Button" => alt="Contact Button" 

と、私はこのコードが優れていると思います。..

$(document).ready(function(){ 
    $(".shopNowButton").hover(function() { 
      $(this).attr("src","images/shopNow.png"); 
       }, function() { 
      $(this).attr("src","images/shopNowHover.png"); 
     }); 
    }); 

    $(".contactButton").hover(function() { 
      $(this).attr("src","images/contactButtonHover.png"); 
       }, function() { 
      $(this).attr("src","images/contactButton.png"); 
     }); 
}); 
+0

ちょうどホバー効果ではなく、コンタクトボタンがクリックされたときにショップナウボタンがオフになりたい、あなたの答えに感謝します。しかし、このページの1番目の答えでは解決されていません。 –

関連する問題