2013-04-30 72 views
0

我在使用二十二岁儿童主题制作的wordpress网站中使用了花式框2。我需要它,当你将鼠标悬停在图像上时,它会显示人名,当你点击图像时,它会有几段描述。除了悬停部分之外,我有一切工作,当你悬停时它显示整个大描述。单独悬停在fancybox中的图像描述2

Here is a link to the page.(密码是boogiebop)

这里是JavaScript:

jQuery(document).ready(function() { 
jQuery(".fancybox").fancybox({ 
    beforeshow: function(){ 
    this.title = $(this.element).next('.newTitle').html(); 
    }, 
    helpers: { 
    title : { 
    type : 'inside' 
    } 
    } 
}); // fancybox 
}); // ready 

我曾尝试添加此:

<a class="fancybox" href="images/01.jpg" title="only show this on hover"><img src="images/01t.jpg" /></a> 
<div class="newTitle" style="display: none;"><p>hello, visite my site <a href="http://fancyapps.com/fancybox/">http://fancyapps.com/fancybox/</a></p></div> 

但无济于事我得到的是标准标题。

+0

它不适合你的原因是因为回调的名称不是'beforeshow',而是'beforeShow'(它使用[CamelCase](http://en.wikipedia.org/wiki/CamelCase)格式) ...查看更多http://stackoverflow.com/a/9611664/1055987 – JFK 2013-04-30 18:20:27

回答

0

你的描述是在title属性里面,并且它会显示孔的内容。您可以添加另一个描述,如des="blablabla",并且一旦您单击图像,屏幕上将显示一个modal box,其中将显示des属性将传递到模式框的内容。

实施例:

$("#image").click(function(){ 

var des = $(this).attr("des"); 

$("#modalbox").html(des); 
//done :D 
}) 

注:我用Jquery的。

+0

嗨,你好,你认为我不应该使用花哨的盒子,而是使用模式框?我不担心在解锁中有href链接,只想悬停说出人物名称,然后点击图片下方的描述... – 2013-04-30 14:17:58

+0

是一样的,fancybox只是css风格。你必须插入一个像div这样的html标签,并且一旦你点击图片,它就会将属性des(或者其他名称与你想要的名称)的值和.html() function写入div中。 – 2013-04-30 14:28:45

+0

好酷,好的一个,我会试试 – 2013-04-30 14:34:32