Fancybox 2,将标题描述更改为alt

时间:2012-12-06 20:07:02

标签: jquery fancybox

我有这样的链接

<a class="fancybox-effects-c" rel="gallery1" href="images/large/9.png"  title="project description here >> <a href='http://www.google.com'target='_blank'>View website</a>"> <img src="images/thumbs/107.png" alt="" /></a>

但是在悬停时会显示代码。在经历了很多事情之后,我决定将标题描述切换到alt字段可以解决我的问题,但无法弄清楚如何做到这一点。 我在jquery.fancybox.js文件中假设它,我只需要切换它。有人可以帮忙吗?

更新:我找到了一个更好的解决方案,而没有将标题描述移到alt字段我可以使用此代码禁用悬停功能

var tempTitle = "";
$('a[title]').hover(
function(e){
     e.preventDefault();
     tempTitle = $(this).attr('title');

     $(this).attr('title', '');

         $(this).mousedown(
            function(){
                $(this).attr('title', tempTitle);
            }
        );
 }
 ,
 function() {
   $(this).attr('title', tempTitle);
 }
 );

像魅力一样!

2 个答案:

答案 0 :(得分:0)

如果有这个html:

<a class="fancybox-effects-c" rel="gallery1" href="images/large/9.png"><img src="images/thumbs/107.png" alt="project description here &gt;&gt; <a href='http://www.google.com'target='_blank'>View website</a>" /></a>

.... fancybox的通缉标题位于alt标记(缩略图)的img属性中,然后使用此代码:

$(document).ready(function() {
    $(".fancybox-effects-c").fancybox({
        beforeShow: function() {
            this.title = $(this.element).find('img').attr('alt');
        }
    }); // fancybox
}); // ready​

注意我使用&gt;代替>来避免脚本问题。

参见 DEMO

答案 1 :(得分:-1)

试试这个:

<a class="fancybox-effects-c" 
   rel="gallery1" href="images/large/9.png" 
   title="project description here >> <a href='http://www.google.com' target='_blank'>View website</a>">
<img src="images/thumbs/107.png" alt="" />
</a>

target

中的title之前没有空格
相关问题