$(".TipAllImg").mouseover(function(e){
var TipAllP = $(this).next().width();
if(e.cancelBubble){
e.cancelBubble = true;
}
if(e.stopPropagation){
e.stopPropagation();
}
$(this).next().css({"display":"block","width":"0"}).animate({width:TipAllP},"slow");
}
这个代码实现的功能是当鼠标放到一个标签上时,让他后面的标签显示。其中的e是代表event对象吗?
这两个if语句都有点看不太懂,能帮着稍微解释下吗?
如果想让鼠标移开时,让后面的标签消失,那不就是将这些代码全部复制,然后将最后一行的css中display:block改成display:none就行了吗?但是效果不好~请问应该怎么样做?
var TipAllP = $(this).next().width();
if(e.cancelBubble){
e.cancelBubble = true;
}
if(e.stopPropagation){
e.stopPropagation();
}
$(this).next().css({"display":"block","width":"0"}).animate({width:TipAllP},"slow");
}
这个代码实现的功能是当鼠标放到一个标签上时,让他后面的标签显示。其中的e是代表event对象吗?
这两个if语句都有点看不太懂,能帮着稍微解释下吗?
如果想让鼠标移开时,让后面的标签消失,那不就是将这些代码全部复制,然后将最后一行的css中display:block改成display:none就行了吗?但是效果不好~请问应该怎么样做?
e.cancelBubble = true;
}
if(e.stopPropagation){
e.stopPropagation();
}
这2个if的功能是取消事件冒泡,第一个if是为了兼容IE的,第二个是其他的主流浏览器所使用的代码。不过jquery已经封装了这些兼容性代码,直接e.stopPropagation()就行了。
鼠标移开后消失的代码是:
$(".TipAllImg").mouseout(function(e){
e.stopPropagation();
$(this).next().css('display', 'none');
}
e.cancelBubble = true;
}
if(e.stopPropagation){
e.stopPropagation();
}
这2个if的功能是取消事件冒泡,第一个if是为了兼容IE的,第二个是其他的主流浏览器所使用的代码。不过jquery已经封装了这些兼容性代码,直接e.stopPropagation()就行了。
鼠标移开后消失的代码是:
$(".TipAllImg").hover(function(e){
e.stopPropagation();
var TipAllP = $(this).next().width();
$(this).next().css({"display":"block","width":"0"}).animate({width:TipAllP},"slow");
}, function(e){
e.stopPropagation();
$(this).next().css('display', 'none');
});