在canvas元素内的javascript中为新Image()设置边框颜色

时间:2013-08-01 08:40:56

标签: javascript jquery

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

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

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

1 个答案:

答案 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