【问题标题】:Galleriffic plugin extra spacesGalleriffic 插件额外空间
【发布时间】:2013-03-17 20:43:59
【问题描述】:

我使用的是 jquery Galleriffic 插件,这里是脚本生成的部分代码:

    <div id="slideshow" class="slideshow">
<span class="image-wrapper current" style="opacity: 1; ">
<a class="advance-link" rel="history" href="#2" title="Title #0">
&nbsp;<img alt="Title #0" src="images/products/Classic.jpg"></a></span></div>

img 标签前的这个空格导致图像显示在错误的位置,我不知道脚本为什么会生成这样的空格,但我想我应该删除空格。

我尝试了以下代码,但没有成功。

$('a.advance-link').text( $('a.advance-link').text().replace(/\s+/g, "") );

我也试过这个

$('a.advance-link:contains("&nbsp;")').html(function(i, h) {
                        return h.replace(/\s+/g, '');
                      });

但没有运气,有人能弄清楚我将如何删除它吗?

谢谢

【问题讨论】:

    标签: jquery jquery-plugins galleriffic


    【解决方案1】:

    看了一下插件。

    // Construct new hidden span for the image
    var newSlide = this.$imageContainer
    .append('<span class="image-wrapper current"><a class="advance-link" rel="history" href="#'+this.data[nextIndex].hash+'" title="'+imageData.title+'">&nbsp;</a></span>')
    .find('span.current').css('opacity', '0');
    
    newSlide.find('a')
        .append(imageData.image)
        .click(function(e) {
            gallery.clickHandler(e, this);
    });
    

    您会注意到它首先构造您正在谈论的字符串,然后将 imageData 附加到锚点中。结果是&amp;nbsp; 标记永远不会被替换。您可以尝试简单地将 .append(imageData.image) 更改为 .html(imageData.image) 并查看是否不能解决您的问题。

    【讨论】:

    • 这是一个非常聪明的处理方式,但不幸的是它没有用,我什至尝试删除  但它仍然出现在代码中
    • @Digital fortress 这很奇怪。你能不能碰巧弄个jsFiddle?
    • 我觉得修复插件需要这么多时间,去掉多余的空间来修复代码中的bug不是更容易吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多