开发者

Add variables into .append

Here is my code so far.

function img_find() {
  var imgs = document.getElementsByT开发者_JS百科agName("img");
  var imgSrcs = [];

  for (var i = 0; i < imgs.length; i++) {
    imgSrcs.push(imgs[i].src);  
  }

  return imgSrcs;
}


var img_find = img_find();

for(var i = 0; i < img_find.length; i++){
  document.write("<img src='" + img_find[i] + "'/>");
}

This returns all of the images on the current page and displays them in image form.

However I am loading this through a bookmarklet on an external .js page.

So what I am trying to do is have it write those images in something like this

image = img_find();
if ((s != "") && (s != null)) {
  $("body").append(" THIS IS WHERE THE DOC WRITE SHOULD GO ");
}

However I can't get this part:

var img_find = img_find();

for(var i = 0; i < img_find.length; i++){
    document.write("<img src='" + img_find[i] + "'/>");
}

To be visible.

Ultimately what ever output from the document.write after the for I want to show up in the .append.

Any thoughts?


You mean

for(var i=0; i < image.length; i++){
    $("body").append("<img src='"+image[i]+"'/>");
}

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜