使用jquery将完整的照片路径添加到img src

时间:2012-06-19 08:28:51

标签: jquery image

 <img id="lotImgtemp" src="" height="148px" width="200px" border="0">
    var photonames=$("#loyaltymemPhoto").val();     //1.jpg         
    $("#lotImgtemp").attr("src","localhost/sumerdia/uploaded_photos/'+ photonames +'");

如何将值添加到img src?

输出我得到相同的"localhost/sumerdia/uploaded_photos/'+ photonames +'"

我需要的输出是"localhost/sumerdia/uploaded_photos/1.jpg"

1 个答案:

答案 0 :(得分:2)

而不是

$("#lotImgtemp").attr("src","localhost/sumerdia/uploaded_photos/'+ photonames +'");

尝试

$("#lotImgtemp").attr("src","localhost/sumerdia/uploaded_photos/"+ photonames);