//construtor created
function Blog(text, date, image) {
this.show_image = function(src, width, height, alt){
var img = document.createElement("img");
img.src = src;
img.width = width;
img.height = height;
img.alt = alt;
document.body.appendChild(img);
}
}
//instance
var blog = [new Blog("hello!,Welcome to my blog1.", new Date("10/21/2012"),'show_image("images/overlay.png", 20,30, "Google Logo")'),
嘿m调用上面的实例中的图像,因为我写了一个函数show_image执行该部分,但图像没有得到显示...请告诉我这里有什么问题...请修改它...我是JavaScript编程新手.. 我如何在JavaScript对象中显示图像作为属性
您是否在某处调用了show_image()? – Uby
当调用函数show_images时,您已将其封装在单引号内。删除它,以便函数得到执行。 – hop
嘿它的内部的实例,你可以看到它的第三个属性,其中m调用overlay.png图像 – king