簡體   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