2013-06-06 53 views
2

我知道这个问题有几个问题,但我似乎无法找到解决方案。当用户将鼠标悬停在具有title属性的定位标记上时,我想隐藏本机工具提示操作。我不想删除标题,因为它被Fancybox使用,我只想删除默认的工具提示操作。隐藏jQuery问题的工具提示

这是我想要使用的脚本,但是当我代替“抑制”类名这是行不通的:

// Suppress tooltip display for links that have the classname 'suppress' 
var links = document.getElementsByTagName('a'); 
for (var i = 0; i < links.length; i++) { 
if (links[i].className == 'suppress') { 
    links[i]._title = links[i].title; 
    links[i].onmouseover = function() { 
     this.title = ''; 
    } 
    links[i].onmouseout = function() { 
     this.title = this._title; 
    } 
    } 
} 

这里是HTML:

<li class="item-thumbs span3 photography"> 
<a class="hover-wrap fancybox1" data-fancybox-group="gallery" href="_include/img/work/full/image-04-full.jpg" title="text about the project :: <a href='http://www.someclient.com'>Launch website</a>"> 
<span class="overlay-img"></span> 
<span class="overlay-img-thumb font-icon-search"></span> 
          </a> 

对于这个愚蠢的问题抱歉,我只能找到适合我的具体情况的所有建议的解决方案。

回答

3

另一种选择是使用(HTML5)data-fancybox-title属性(的fancybox版本2.x)。它不显示悬停但仍然是使用的fancybox ....而不需要使用回调,这样

这个网站

<a data-fancybox-title="Lorem ipsum" class="fancybox" href="http://fancyapps.com/fancybox/demo/1_b.jpg"><img src="http://fancyapps.com/fancybox/demo/1_s.jpg" alt=""/></a> 

这个脚本

$(".fancybox").fancybox(); 

...将工作得很好;见JSFIDDLE

+0

谢谢你。有没有什么理由可以推荐使用其他选项?只是好奇。 – user2247476

+0

@ user2247476:我只会在严格需要时才使用回调。 'data-fancybox-title'已经集成在代码中,所以不需要执行额外的功能。 – JFK

1

如果使用fancybox2:

$(".fancybox") 
.fancybox({ 
    beforeLoad: function() { 
     this.title = $(this.element).attr('caption'); 
    } 
}); 

看到exsample http://jsfiddle.net/vkDcG/