我無法顯示來自文件URL的照片。我只在網頁上獲得[Object HTML IMAGE ELEMENT]
,即使我認爲我將此元素指向圖像源。從圖像中顯示圖像uri
//database query results...
for(var i = 0; i < len; i++){
theID = results.rows.item(i).id;
console.log(theID);
theName = results.rows.item(i).username;
htmlStr += theName;
console.log(theName);
thePhoto = results.rows.item(i).imagepath;
console.log(thePhoto);
var imageHold= new Image();
imageHold.src = thePhoto;
console.log("this is the src:"+imageHold.src);//THIS IS GIVING ME THE PATH
var userDiv = document.createElement("div");//Create the div
userDiv.innerHTML=htmlStr+imageHold;//IS THE PROBLEM WHAT I AM DOING HERE?
document.getElementById('showUsers').appendChild(userDiv);//append it to the document
userDiv.style.display = 'block';
}
感謝馬塞爾,我學習,所以我有時會明白我需要做的,但不知道如何將它標記,如果你明白我的意思。例如,這是工作,但現在我不知道如何給它的大小和寬度屬性。是否有一個確定標記約定的資源? – Inkers
你的意思是賦予圖像屬性?只需使用'imageHold.style。[...]'來更改內聯樣式屬性。 – marekful