0

如何在 javascript 中为图像变量设置边框颜色?

var img= new Image();
  img.onload=function(){
    // how can i set the border color 
  };
 img.src="url.png";

http://jsfiddle.net/H2k5W/61/

4

1 回答 1

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

于 2013-08-01T09:14:50.260 回答