jquery鼠标移上div切换
样式:
.tb_box{ padding:20px; position: absolute; left:0; right:0; width: 50%;margin:auto; background:#eee;}
.tb_box span{display:block; padding:20px; width:120px; margin:0 auto; text-align:center; border:solid 1px #ddd; }
.tb_box span.t2{border:solid 1px #F1080C;}
页面结构:
<div class="tb_box">
<span class="t1">
产品详细
</span>
<span class="t2">
<a href="#">确认</a>
</span>
</div>
js代码:
var is_block=false;
var t2=$(".tb_box span.t2").hide();
$(".tb_box span.t1").mouseover(function(){
$(this).hide();
t2.show();
});
t2.mouseover(function(){
is_block=true;
$(this).show();
$(".tb_box span.t1").hide();
});
t2.mouseout(function(){
if(is_block){
$(this).hide();
$(".tb_box span.t1").show();
is_block=false;
}
});
还没有评论,来说两句吧...