我使用的是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">
<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(" ")').html(function(i, h) {
return h.replace(/\s+/g, '');
});但是运气不好,有没有人能想出我该怎么移除它呢?
谢谢
发布于 2013-01-25 17:09:40
看了一下插件。
// 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+'"> </a></span>')
.find('span.current').css('opacity', '0');
newSlide.find('a')
.append(imageData.image)
.click(function(e) {
gallery.clickHandler(e, this);
});您会注意到,它首先构造您正在讨论的字符串,然后将imageData附加到锚点中。结果是 标记永远不会被替换。您可以尝试简单地将该.append(imageData.image)更改为.html(imageData.image),看看这是否不能解决您的问题。
https://stackoverflow.com/questions/14518355
复制相似问题