比方说,我有4个具有相同类的img标签,每个标签具有不同的url。我可以用这个代码检索每个网址:每个类每个链接追加一次
$('.userPicture img').each(function(){
var getImageLink = $(this).attr('src');
console.log(getImageLink)
});
CONSOLE.LOG:
http://link1.com
http://link2.com
http://link3.com
http://link4.com
的quesion是如何每一个环节每类追加只有一次?
$.each(getImageLink, function(i) {
$('.aboutInfo').eq(i).append('<p><a href="'+getImageLink+'"></a></p>');
});
最好成绩,我可以得到的是:
.aboutInfo
http://link1.com
http://link2.com
http://link3.com
http://link4.com
.aboutInfo
http://link1.com
http://link2.com
http://link3.com
http://link4.com
我需要的是:
.aboutInfo
http://link1.com
.aboutInfo
http://link2.com
等等
我不能myselft弄明白:(
在''和''之间添加没有文字的链接不会有任何用处(它只是一个零长度链接)。你能解释你想完成什么吗?你想在链接中点击哪些文字? – jfriend00 2011-12-22 00:23:07
该链接可以有一个与之相关的背景图片... – brandwaffle 2011-12-22 00:29:47
@brandwaffle - 我没有看到任何迹象表明这是OP正在尝试做的事情,没有任何东西可以让链接任意大小,甚至没有任何大小来显示背景图片。我认为OP只是留下了一些他们想做的事情。 – jfriend00 2011-12-22 00:45:51