怎么给JS代码中的图片加超链接?

JavaScript07

怎么给JS代码中的图片加超链接?,第1张

imgArr.map(imglink =>{

const atags = document.createElement('a')

const imgtags = document.createElement('img')

imgtags.src = imglink.path

atags.href = imglink.path

atags.appendChild(imgtags)

})

document.getElementById("imageId").onclick = function(){

window.location.href = url

}

添加点击事件,跳转链接就可以了