2

我知道有一些与此问题相关的问题,但是我似乎无法为我的案例找到解决方案。当用户将鼠标悬停在具有标题属性的锚标记上时,我想隐藏本机工具提示操作。我不想删除标题,因为它被 Fancybox 使用,我只想删除默认的工具提示操作。

这是我正在尝试使用的脚本,但是当我替换“抑制”类名时它不起作用:

// 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>

为这个愚蠢的问题道歉,我可以在所有适用于我的具体案例的建议中找到一个解决方案。

4

2 回答 2

3

Another option is to use the (HTML5) data-fancybox-title attribute (fancybox v2.x). It doesn't show on hover but still it's used by fancybox .... and not need of using callbacks so

this html

<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>

and this script

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

... will work just fine; see JSFIDDLE

于 2013-06-06T04:42:36.557 回答
1

如果使用fancybox2:

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

参见示例http://jsfiddle.net/vkDcG/

于 2013-06-06T02:35:41.827 回答