<div class="yaosu1">
<p><input type="checkbox" checked="" name="category" value="锅炉" οnclick="my_func('锅炉')">锅炉 </p>
<p><input type="checkbox" checked="" name="category" value="电梯" οnclick="my_func('电梯')">电梯</p>
<p><input type="checkbox" checked="" name="category" value="压力管道" οnclick="my_func('压力管道')">压力管道</p>
<p><input type="checkbox" checked="" name="category" value="客运索道" οnclick="my_func('客运索道')">客运索道</p>
</div>
==
Html中使用自定义图片来实现checkbox显示如果需要使用图片来实现checkbox的使用,可以使用来实现,实现原理是将label表签代替checkbox的显示,将checkbox的display设置为none,在label标签中使用要显示的图片img,再使用js函数去控制图片的选中与否的切换。
<label for="agree" >
<img class="checkbox" alt="选中" src="../img/checked.png" id="checkimg" οnclick="checkclick();">
</label>
<input type="checkbox" style="display:none" id="agree" checked="checked">
<script>
function checkclick(){
var checkimg = document.getElementById("checkimg");
if($("#agree").is(':checked') ){
$("#agree").attr("checked","unchecked");
checkimg.src="../img/unchecked.png";
checkimg.alt="未选";
} else{
$("#agree").attr("checked","checked");
checkimg.src="../img/checked.png";
checkimg.alt="选中";
}
}
</script>
==