これがかなり一般的な質問である場合は申し訳ありませんが、過去2日間を読んで、自分でそれを理解できるかどうかを確認しました.アドバイス。私はまだJavaScriptの学習の初期段階にあります。
基本的に、微妙なテクスチャを与える繰り返しの背景画像を持つ div クラスに含まれる一連のサムネイルがあります。また、マウスがサムネイル画像の上にあるときに、個々の div コンテナーを青色で強調表示する Java スクリプトもあります。私が抱えている問題は、サムネイルの div 用に選択した既存の背景画像と、青一色の効果がうまくかみ合わないことです。青いホバー効果が発生している間、背景画像のオン/オフを切り替えようとしましたが、マウスを 1 回オーバー/ホバーした後に永続的にオフにすることしかできませんでした。
これがJavaScriptです:
// this controls the entire div tag and turns it blue
$('.pGrid div a').hover(
function(){
//this if-statement should toggle whether or not the striped background shows when the mouse is hovering
if ($('.pGrid div a').hover !=0) {
$('.pGrid div a').parent().css({ backgroundImage: "none" });
}
else {
$('.pGrid div a').parent().style({ backgroundImage: "url('../images/background_stripes_white.gif')" });
}
//mouse over turn div blue
$(this).parent().stop().animate({
backgroundColor: "#006699",
color: "#ffffff"
}, 350);
// this controls the word-highlight part
$(this).stop().animate({
backgroundColor: "#006699",
color: "#ffffff"
}, 350);
},
// mouse out
function(){
$(this).parent().stop().animate({
backgroundColor: "#d0d0d0",
color: "#000000"
}, 350);
$(this).stop().animate({
backgroundColor: "#d0d0d0",
color: "#006699"
}, 350);
});