【问题标题】:Trigger existing fancybox with a href用href触发现有的fancybox
【发布时间】:2011-10-15 14:26:54
【问题描述】:

所以我真的被困在这一点上。 就我而言,我有一个带有图片的画廊。

在主图像上是一个href,用他的子图片触发fancybox。 这行得通,np。

现在我有了一个带有 href 和文本的页脚.. 当我单击此链接时,它必须从带有子图片的主图像中打开 Fancybox。

是的,这可以通过一个简单的 href 来实现。是的,您会在您的图库中获得一张重复的图片。我不需要冗余。

帮助我,我会保证在我们与 Apple 的战争中提供帮助。

代码sn-p:

echo '<ul style="padding:0;">';
       $query = "  SELECT 
            * 
           FROM 
            fotos AS f
           WHERE f.id = '29'
           ";

       #echo $query;
       $result = mysql_query($query) or die(mysql_error());
       $count = 0;   
       while($row = mysql_fetch_array($result))
       { $count++;
        echo '<div style="float:left;margin-top:5px;"><a style="text-decoration:none;color:black;" rel="gal_'.$row['id'].'"  href="'.$row['fotos'].'"
        title="<b>Navigeren met de pijltoetsen door het album</b>">
        <img src="'.$row{"fotos"}.'" border="0" />   

        </a>';
        if($count == 1)
        </div></div>';

        $result2 = mysql_query("SELECT * FROM fotos WHERE type ='".$row['id']."'") or die(mysql_error());   
        while ($row2 = mysql_fetch_array($result2))
        {
         echo '<a rel="gal_'.$row2{"type"}.'" href="'.str_replace('....', '..', $row2{"fotos"}).'" title="'.$row2{"omschrijving"}.'" style="display:none"></a>';
        }
       }

 echo '</ul>';

所以这是我的画廊。

现在我得到了一个href .. 使用下面的链接从这里我想触发上面的fancybox。

echo '<div id="foto_footer"> <a style="color:white;text-decoration:none;" title="<b>Navigeren met de pijltoetsen door het album</b>" id="openalbum" >Bekijk de diashow</a>

【问题讨论】:

  • 哪场战争?我错过了什么吗?
  • 三星开发者来到 Stackoverflow :)
  • 你需要的东西不好理解,能贴代码吗?

标签: jquery html fancybox


【解决方案1】:

您可以触发点击其他链接,例如,

$("#second_link").click(function() {
    $(#first_link").trigger("click");
});

或者您可以创建多次不使用的项目数组 -

var items = [
    '1.jpg',
    '1.jpg',
    {
        'href'  : '3.jpg',
        'title' : 'Lorem ipsum'
    }
];

var opts = {
    'padding'   : 0,
    'type'      : 'image'
};

$(".open_manually").click(function() {
    $.fancybox(items, opts);
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 2021-06-24
    相关资源
    最近更新 更多