我试图在悬停时删除链接的标题属性,然后在鼠标移出时将其添加回来.我想将var hoverText传递给悬停…
这是我的代码.有任何想法吗?
- $(".icon a").hover(function() {
- $this = $(this);
- var hoverText = $.data(this,'title',$this.attr('title'));
- $(this).find("em").animate({opacity: "show",top: "-35"},"slow");
- $(this).find("em").text(hoverText);
- $this.removeAttr('title');
- },function(hoverText) {
- $(this).find("em").animate({opacity: "hide",top: "-45"},"fast");
- $(this).attr("title",hoverText);
- });
解决方法
将“hoverText”作为全局变量.
- var hoverText = '';
- $(".icon a").hover(function() {
- $this = $(this);
- hoverText = $.data(this,function() {
- $(this).find("em").animate({opacity: "hide",hoverText);
- });