6

我正在尝试在我的网站上使用从 reStructuredText 生成的 jQuery lightBox 实现。灯箱将图像周围链接的标题作为灯箱显示中图像的标题。

但是,我似乎无法在 reStructuredText 中找到在链接上提供标题属性的方法 - 有人知道这样做的方法吗?我的图像定义如下:

.. image:: image001.thumb.jpg
    :alt: Some alt text here
    :target: image001.jpg

所以我可以添加一个alt属性,但不能添加一个标题。一种可能的替代方法是使用目标作为参考,如下所示:

.. image:: image001.thumb.jpg
    :alt: Some alt text here
    :target: image1_

.. _image1: image001.jpg

在后一种情况下,我不确定如何向底部定义的链接添加属性(如果可能的话)。

4

1 回答 1

0

我假设(试试看!),初始化灯箱后灯箱不再需要标题属性。因此,如果您想提供图像 alt-attributes 作为标题,则应该这样做,如果您在灯箱初始化后调用它:

function alt_2_title () {
    $("img[alt]").each(function(){
        $(this).attr('title', $(this).attr('alt'));
    });
});

这会将每个具有 alt 属性的图像的 alt 复制到标题;如果您只想修改几张图片,您可以使用类似...

function alt_2_title (name_of_container) {
    $("img[alt]", "#"+name_of_container).each(function(){
        $(this).attr('title', $(this).attr('alt'));
    });
});
于 2011-04-06T14:25:02.113 回答