制作Lightbox Link外部网页

时间:2011-11-21 00:59:21

标签: hyperlink lightbox

如果我有一个灯箱库,是否可以将其中一个图像链接到外部网站?因此,其他图像被视为常规灯箱,但如果您点击其中一个图像,您将被发送到外部网页?

此解决方案不起作用:

<div id="gallery" style="display:inline;">
    <ul>
        <li>
            <a href="http://www.linktohere.com" >
                <img src="photos/thumb_image1.jpg" width="72" height="72" alt="" />
            </a>
        </li>
        <li>
            <a href="photos/image2.jpg" title="Utilize a flexibilidade dos seletores da jQuery e crie um grupo de imagens como desejar. $('#gallery a').lightBox();">
                <img src="photos/thumb_image2.jpg" width="72" height="72" alt="" />
            </a>
        </li>
        <li>
            <a href="photos/image3.jpg" title="Utilize a flexibilidade dos seletores da jQuery e crie um grupo de imagens como desejar. $('#gallery a').lightBox();">
                <img src="photos/thumb_image3.jpg" width="72" height="72" alt="" />
            </a>
        </li>
    </ul>
</div>

有什么方法可以解决这个问题吗?

感谢。

1 个答案:

答案 0 :(得分:0)

<htm>
<head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('#gallery a').next().lightBox();
        });
    </script>
    <title>Untitled Document</title>
</head>
<body>
<div id="gallery" style="display:inline;">
    <ul>
        <li>
            <a href="http://www.linktohere.com" >
                <img src="photos/thumb_image1.jpg" width="72" height="72" alt="" />
            </a>
        </li>
        <li>
            <a href="photos/image2.jpg" title="title one">
                <img src="photos/thumb_image2.jpg" width="72" height="72" alt="" />
            </a>
        </li>
        <li>
            <a href="photos/image3.jpg" title="title two">
                <img src="photos/thumb_image3.jpg" width="72" height="72" alt="" />
            </a>
        </li>
    </ul>
</div>
</body>
</html>

你可以使用函数.next()来获取下一个元素,所有其他元素将被选中,免除第一个元素。

使用这样的查询更常见,通常更具可读性。