如何为使用以下javascript创建的图像添加链接。如何使用javascript添加链接到使用javascript创建的图像元素
感谢您的任何帮助或答复。
for(var i=0; i<images.length; i++) {
var t = document.createElement('IMG');
t.setAttribute('src',images[i]);
t.setAttribute('border', 0);
t.setAttribute('width',imageWidth);
t.setAttribute('height',imageHeight);
t.style.position = 'absolute';
t.style.visibility = 'hidden';
el.appendChild(t);
}
它不在HTML文档上使用'setAttribute'是个好主意。有很多情况下,这在IE中失败(尽管不是你打的)。首选DOM Level 1 HTML属性:'t.src = images [i];'等 – bobince 2010-04-12 11:04:07