开发者

Add variables into .append

开发者 https://www.devze.com 2023-03-01 17:34 出处:网络
Here is my code so far. function img_find() { var imgs = document.getElementsByT开发者_JS百科agName(\"img\");

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

精彩评论

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