【发布时间】:2011-08-22 10:14:01
【问题描述】:
我想在 HTML 的复选框中添加图像,这样当我单击复选框时,它应该被图像替换。有什么方法可以做到?
【问题讨论】:
标签: html
我想在 HTML 的复选框中添加图像,这样当我单击复选框时,它应该被图像替换。有什么方法可以做到?
【问题讨论】:
标签: html
设 cb 为复选框,src 为要显示的图片来源。
cb.onclick = function(){
if(!this.img){
var img = this.img = document.createElement("image");
img.src=src;
img.cb = this;
img.onclick = function(){
this.parentNode.replaceChild(this.cb,this);
}
}
this.parentNode.replaceChild(this.img,this);
}
【讨论】: