【发布时间】:2013-09-14 00:11:24
【问题描述】:
我有css:
.frame{
height:200px;
width:200px;
border-style:solid;
border-width:3px;
}
.test2{
opacity:0;
}
我有 html
<div class="frame">
<span class="test test2">qwerty</span>
</div>
当鼠标在 .frame 上时,我想将 .test2 类删除到 .test,当鼠标在 leave.frame 上时,我想将 .test2 添加到 .test。 所以我的jQuery代码是:
$(document).on('mouseenter mouseleave', '.frame', function( e ) {
var $el=$(this),
mEnt = e.type == "mouseenter";
if(mEnt == true){
el.find('.test').removeClass('test2');
}else{
el.find('.test').addClass('test2');
}
});
但它不起作用,.test2 不想从 .test 中删除。 这是一个jsfiddle:http://jsfiddle.net/malamine_kebe/EmE7p/
【问题讨论】:
-
只需检查控制台就可以节省您提出这个问题的时间
标签: jquery opacity removeclass mouseenter