jQueryホバー効果に問題があります。基本的にChromeとIEのバージョンでは完全に機能していますが、Firefoxでは動作しません。jQuery Hover - Firefoxで動作していない
非常にシンプルなjQueryコードですが、なぜ動作しないのかわかりません。 jQueryをデバッグするための優れたツールはありますか?
http://www.ryansammut.com/jQueryHover.html
jQueryホバー効果に問題があります。基本的にChromeとIEのバージョンでは完全に機能していますが、Firefoxでは動作しません。jQuery Hover - Firefoxで動作していない
非常にシンプルなjQueryコードですが、なぜ動作しないのかわかりません。 jQueryをデバッグするための優れたツールはありますか?
http://www.ryansammut.com/jQueryHover.html
あなたのセレクタに
$(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");
});
});
contactButtonMenuの代わりに '#contactButtonMenu'を追加するだけで動作します。ありがとう:) –
@RyanSammut cool :) btw、JSをデバッグするためにfirebugを使用できます。それはイベントが正常に呼ばれていることを示します。セレクタが何も返さなかったということだけです。 – JohnP
を '#' が欠けているあなたは一つだけ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"
ホバリングはいいです、あなたが私に与えた効果は、私が欲しいものではありませんが、alt問題を発見してくれてありがとう。私が必要とするものは、Contact Hoverにあるので、Shop NowのHoverはオフになります。 –
、それを置き換える
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");
});
});
ちょうどホバー効果ではなく、コンタクトボタンがクリックされたときにショップナウボタンがオフになりたい、あなたの答えに感謝します。しかし、このページの1番目の答えでは解決されていません。 –
この質問には、サイトのコードを追加してください。 – JohnP
これを追加してください$( '#shopNowButton') – K6t
@ K6t - ありがとうございました。 jQueryのデバッグにはどのツールを使用しますか? –