Now i want to place this link here: I want to replace Upload_Panel.png image with the image in the source aa. Help would b"/>
  简体   繁体   中英

Place src value form javascript to img tag

I need to put the image source which i am getting perfectly to the <img/> place but i don't know how to.

js:

var aa = document.getElementById("TableImage"+getid).src;
alert(aa);

Result of above js:

<code>结果</ code>

Now i want to place this link here:

<!-- Upload Part -->
<div class="ImageUpload">
    <label for="FileInput" style="width: 18px; height: 18px; margin-top: -160px; margin-left: 905px;">
        <img class="UplaodPic" src="../../img/Upload_Panel.png"/>
   </label>

    <input name="picture" id="FileInput" type="file" onchange="readURL(this,'Picture2')" style="cursor: pointer; display: none"/>
</div>

I want to replace Upload_Panel.png image with the image in the source aa . Help would be nice.

How about:

$("#FileInput").prev("label").find("img").attr("src", aa);

(Since this was the only element with an ID, I went with that. No idea how many of those classes you have on your page)

var aa = document.getElementById("TableImage"+getid).src;
$('.uplaodPic').attr('src', aa)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM