.css("background","red"); を削除する方法 .yuimenuitemlabel 要素をホバリングした後に (A.yuimenubaritemlabel.sub) 要素から ?
$(document).ready(function(){
$(".yuimenuitemlabel").mouseover(function(){
$("A.yuimenubaritemlabel.sub").css("background","red");
});
});
.css("background","red"); を削除する方法 .yuimenuitemlabel 要素をホバリングした後に (A.yuimenubaritemlabel.sub) 要素から ?
$(document).ready(function(){
$(".yuimenuitemlabel").mouseover(function(){
$("A.yuimenubaritemlabel.sub").css("background","red");
});
});
マウスを離したときに css プロパティをリセットする必要があります。
$(".yuimenuitemlabel").mouseover(function(){
$("A.yuimenubaritemlabel.sub").css("background","red");
}).mouseleave(function(){
$("A.yuimenubaritemlabel.sub").css("background","");
});
ホバーを使用できる多くのことを行う場合は、ホバー機能を使用します。
$(".yuimenuitemlabel").hover(function(){
$("A.yuimenubaritemlabel.sub").css("background","red");
}, function(){
$("A.yuimenubaritemlabel.sub").css("background","");
});
CSSを変更するだけでよいと仮定して、ホバー機能を使用してください。2 つのクラスを 1 つをサブ、もう 1 つを newsub にすることができます。
$(".yuimenuitemlabel").hover(function(){
$("A.yuimenubaritemlabel.sub").toggleClass("newsub");
});
クラスを追加/削除することをお勧めします
$(document).ready(function(){
$(".yuimenuitemlabel").hover(function(){
$("a.yuimenubaritemlabel.sub").toggleClass('hoverclass');
});
});
そして、クラスを使用します
.hoverclass{
background-color:red;
}