分享这个和 jquery 帮助

发布于 2024-11-30 21:58:29 字数 2263 浏览 3 评论 0原文

我有一些看起来像这样的 HTML,

<div class="suit-gallery">
  <img src="../images/galleries/business/DSC_0035_sm.jpg" alt="Stylish button 2 business suit with contrast buttonholes light weight high twist cool wool" width="164" height="247" />
  <div class="suit-gallery-btn">
    <a href="../images/galleries/business/DSC_0035.jpg" rel="lightbox[business]" title="Stylish button 2 suit with contrast buttonholes light weight high twist cool wool Holland &amp; Sherry from £695, choice of 90 designs/colours">Click for more information</a>
</div>
</div>

<div class="suit-gallery">
  <img src="../images/galleries/business/DSC_0010_sm.jpg" alt="Classic button 2 business suit with an out ticket pocket. Grey wool Holland &amp; Sherry Perennial" width="164" height="247" />
  <div class="suit-gallery-btn">
    <a href="../images/galleries/business/DSC_0010.jpg" rel="lightbox[business]" title="Classic button 2 suit with an out ticket pocket. Grey wool Holland &amp; Sherry Perennial from £895, choice of 120 designs/colours" >Click for more information</a>
</div>
</div>

<div class="clear">&nbsp;</div>

<div class="suit-gallery">
  <img src="../images/galleries/business/DSC_0024_sm.jpg" alt="Modern 2 button business suit grey 100% Yorkshire worsted" width="164" height="247" />
  <div class="suit-gallery-btn">
    <a href="../images/galleries/business/DSC_0024.jpg" rel="lightbox[business]" title="Modern 2 button suit 100% Yorkshire worsted from £795 choice of 85 designs/colours" >Click for more information</a>
</div>

我想向 .suit-gallery-btn 的每个实例添加一个 sharethis 邮件链接,但是我不知道如何做到这一点,我也想标题选项中链接的链接标题,以及图像选项中的图像 URL,下面是我目前所拥有的,

jQuery(document).ready(function(){
    stWidget.addEntry({
    "service":"email",
    "element": document.getElementById('button_1'),
    "url":"http://sharethis.com",
    "title":"What do you think to this suit?",
    "type":"large",
    "text":"What do you think to this suit?" ,
    "image": "",
    "summary":""
    });
});

我也知道我必须根据类而不是 id 选择元素,我需要为无论多少人都这样做.suit-gallery-btn 有。

我完全迷失了。

I have some HTML that looks like this,

<div class="suit-gallery">
  <img src="../images/galleries/business/DSC_0035_sm.jpg" alt="Stylish button 2 business suit with contrast buttonholes light weight high twist cool wool" width="164" height="247" />
  <div class="suit-gallery-btn">
    <a href="../images/galleries/business/DSC_0035.jpg" rel="lightbox[business]" title="Stylish button 2 suit with contrast buttonholes light weight high twist cool wool Holland & Sherry from £695, choice of 90 designs/colours">Click for more information</a>
</div>
</div>

<div class="suit-gallery">
  <img src="../images/galleries/business/DSC_0010_sm.jpg" alt="Classic button 2 business suit with an out ticket pocket. Grey wool Holland & Sherry Perennial" width="164" height="247" />
  <div class="suit-gallery-btn">
    <a href="../images/galleries/business/DSC_0010.jpg" rel="lightbox[business]" title="Classic button 2 suit with an out ticket pocket. Grey wool Holland & Sherry Perennial from £895, choice of 120 designs/colours" >Click for more information</a>
</div>
</div>

<div class="clear"> </div>

<div class="suit-gallery">
  <img src="../images/galleries/business/DSC_0024_sm.jpg" alt="Modern 2 button business suit grey 100% Yorkshire worsted" width="164" height="247" />
  <div class="suit-gallery-btn">
    <a href="../images/galleries/business/DSC_0024.jpg" rel="lightbox[business]" title="Modern 2 button suit 100% Yorkshire worsted from £795 choice of 85 designs/colours" >Click for more information</a>
</div>

I am wanting to add a sharethis mail link to each instance of .suit-gallery-btn, however I have no idea how do this, I would also like to a title of link of link into the caption option, and also image URL into the image option, below is what I have currently,

jQuery(document).ready(function(){
    stWidget.addEntry({
    "service":"email",
    "element": document.getElementById('button_1'),
    "url":"http://sharethis.com",
    "title":"What do you think to this suit?",
    "type":"large",
    "text":"What do you think to this suit?" ,
    "image": "",
    "summary":""
    });
});

I also know that I will have to select the element based on a class and not the id, I need to do this for however many .suit-gallery-btn there are.

I am toally lost.

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

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

发布评论

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

评论(1

等待我真够勒 2024-12-07 21:58:29

尝试这样的事情:

$(".suit-gallery-btn").each(function(){

    $(this).append("<span class='share-span'></span>"); // ShareThis button will be inserted in this span, which we are appending to each <div class="suit-gallery-btn">

    var suitLink = $(this).find('a'); // the "click more information" link. you will need the href and title from this element.

    stWidget.addEntry({
        "service":"email",
        "element": $(this).find('.share-span')[0],
        "url":suitLink.attr('href'),
        "title":suitLink.attr('title'),
        "type":"large",
        "text":suitLink.attr('title'),
        "image": suitLink.attr('href'),
        "summary":suitLink.attr('title')
    });


});

这是一个 JS 小提琴来演示: http://jsfiddle.net/RR26b/

(无效图像引用和缺少 ShareThis 发布者密钥会导致错误,但这个概念应该可行)

Try something like this:

$(".suit-gallery-btn").each(function(){

    $(this).append("<span class='share-span'></span>"); // ShareThis button will be inserted in this span, which we are appending to each <div class="suit-gallery-btn">

    var suitLink = $(this).find('a'); // the "click more information" link. you will need the href and title from this element.

    stWidget.addEntry({
        "service":"email",
        "element": $(this).find('.share-span')[0],
        "url":suitLink.attr('href'),
        "title":suitLink.attr('title'),
        "type":"large",
        "text":suitLink.attr('title'),
        "image": suitLink.attr('href'),
        "summary":suitLink.attr('title')
    });


});

Here is a JS fiddle to demonstrate: http://jsfiddle.net/RR26b/

(There are errors from invalid image references, and from lack of a ShareThis Publisher Key, but the concept should work)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文