繁体   English   中英

将src值形式的javascript放置到img标签

[英]Place src value form javascript to img tag

我需要将要完美显示的图像源放在<img/>位置,但我不知道该怎么做。

js:

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

Result of above js:

<code>结果</ code>

现在,我想将此链接放在这里:

<!-- 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>

我想用源aa的图像替换Upload_Panel.png图像。 帮助会很好。

怎么样:

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

(因为这是唯一具有ID的元素,所以我去了。不知道您的页面上有多少个此类)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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