老师好,各位同学好
大家好,我想请问一下,我们模拟出来的复选框有效果了,可是点击文字不能选中那个框框这个问题要怎么解决呢?谢谢!
<div class="typeList"> <form method="post" action="#" name="typeList"> <ul id="checkList"> <li class="selected"><input type="checkbox" name="typeList" id="checkBox_xiao"/><label for="checkBox_xiao">消费者保障</label></li> <li>xxxxx</li> <ul> </form> </div>
function checklist() {//点击变换效果 var li = document.getElementById("checkList").getElementsByTagName("li"); for (var i = 0; i < li.length; i++) { li[i].onclick = function () { if (this.className == "selected") { this.className = null; } else { this.className = "selected"; } } } }