如何在javascript中为图像变量设置边框颜色?
var img= new Image();
img.onload=function(){
// how can i set the border color
};
img.src="url.png";
答案 0 :(得分:1)
做类似的事情:
var image = new Image();
image.src = 'http://www.google.com/logos/2011/guitar11-hp-sprite.png';
image.onload = function(){
alert("loaded");
image.style.border='1px solid black';
};
var divele = document.getElementById("test");
divele.appendChild(image);
演示:: jsFiddle