我有这个HTML:
<div id="link-thumbs-list">
<img src="image.php?f=http://www.jetphotos.net/trans.gif&h=72&w=128" />
<img src="image.php?f=http://www.jetphotos.net/logo-nb.jpg&h=72&w=128" />
<img src="image.php?f=http://www.jetphotos.net/trans.gif&h=72&w=128" />
</div>
我需要选择f =(文件url)到每个imgs的src属性中.. 我能怎么做?? Thanksss
答案 0 :(得分:3)
就是这样:
var urls = document.getElements("#link-thumbs-list img").get("src").map(function(el) {
return el.replace("image.php?f=", "").split("&")[0];
});
console.log(urls);
输出:
["http://www.jetphotos.net/trans.gif", "http://www.jetphotos.net/logo-nb.jpg", "http://www.jetphotos.net/trans.gif"]
答案 1 :(得分:0)
$$("#link-thumbs-list img").each(function(elem) {
var m = elem.get("src").match(/f=([^&]*)&/);
if (m && m[1]) {
elem.set("src", m[1]);
}
});