<div class="list_top-title">
<div class="news_fabuxitong_title y0">最新游戏币发布</div>
<div class="news_fabuxitong_title y1">最新套餐发布</div>
</div>
默认“最新游戏币发布”的样式为“news_fabuxitong_title y0”
默认“最新套餐发布”的样式为“news_fabuxitong_title y1”然后如何用JQ实现,鼠标移动到它们之间的一个DIV上时,样式互换。代码越简洁越好。
在线等。
$(function(){
$("div.list_top-title > div").mouseover(function(){
var c1 = $(this).attr('class');
$(this).attr('class',$(this).siblings().attr('class'));
$(this).siblings().attr('class',c1);
})
});
这个明显有BUG。首先放到第一个上面就错了~
$("div.list_top-title > div").each(function(){
var c1 = $(this).attr("class");
$(this).mousemove(function(){
if(c1=="news_fabuxitong_title y0")
{
$(this).attr("class","news_fabuxitong_title y1");
}
else
{
$(this).attr("class","news_fabuxitong_title y0");
}
}).mouseout(function(){
if(c1=="news_fabuxitong_title y0")
{
$(this).attr("class","news_fabuxitong_title y1");
}
else
{
$(this).attr("class","news_fabuxitong_title y0");
}
});
});
$('div.news_fabuxitong_title').hover( function() {
$('div.news_fabuxitong_title').toggleClass('y1 y0');
});
});
$().ready(function(){
$("div.list_top-title > div").each(function(i){
$(this).mousemove(function(){
if(i>=0&&i<3)
{
$(this).attr("class",$(this).next().attr("class"));
}
else
{
$(this).attr("class",$(this).prev().attr("class"));
}
}).mouseout(function(){
if(i>=0&&i<3)
{
$(this).attr("class",$(this).next().attr("class"));
}
else
{
$(this).attr("class",$(this).prev().attr("class"));
}
});
});
});
</script>
mouseover 的时候和mouseout的时候需要怎样互换?
请先说清楚