RestructedText - 向链接添加标题属性

发布于 2024-10-09 16:53:09 字数 537 浏览 0 评论 0原文

我正在尝试在我的网站上使用从 reStructuredText 生成的 jQuery lightBox 实现。 lightBox 将图像周围的链接标题作为 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

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

I am trying to use a jQuery lightBox implementation on my website that is generated from reStructuredText. The lightBox takes the title of the link around the images as the caption of the image in the lightBox display.

However, I can't seem to find a way in reStructuredText of providing a title attribute on a link - does anyone know of a way of doing this? My images are defined like so:

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

So I can add an alt attribute, but not a title. A possible alternative may be to use a target as the reference like so:

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

.. _image1: image001.jpg

In this latter case, I am not sure how to add attributes to the link defined at the bottom (if it is possible at all).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

童话里做英雄 2024-10-16 16:53:09

我假设(尝试一下!),在 lightbox 初始化后,lightbox 不再需要 title 属性。
因此,如果您想提供图像 alt 属性作为标题,那么如果您在 lightbox 初始化之后调用它,则应该这样做:

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'));
    });
});

I assume (try it out!), the title attribute is no longer needed by lightbox after lightbox is initialized.
So if you'd like to provide the images alt-attributes as title, this one should do so, if you call it after lightbox-initialization:

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

This copies alt to title for every image that has an alt-attribute;
If you like to modify only a few images, you might restrict you images selection by using something like ...

function alt_2_title (name_of_container) {
    $("img[alt]", "#"+name_of_container).each(function(){
        $(this).attr('title', $(this).attr('alt'));
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文