用了一个js脚本,是通过id调用的,但是只能调用一次,如何修改能多次调用该脚本,或者有别的方法解决问题
脚本如下
(function () {
var radioWrap = document.getElementById("radio_wrap"),
li = radioWrap.getElementsByTagName("li");
for (var i = 0; i < li.length; i++) {
li[i].onclick = function () {
for (var i = 0; i < li.length; i++) {
li[i].className = "";
}
this.className = "checked";
}
}
})();
前端代码
<div id="radio_wrap">
<span class="GoodsInformation_reight-dt" style="display:inline-block;font-weight:700;margin-top:5px">机身分类</span>
<ul >
<li class="c checked">
<input type="radio" id="radio_a_01" name="radio_a" />
<label for="radio_a_01"><span style="display:inline-block">海风青</span></label>
<i></i>
</li>
<li class="c">
<input type="radio" id="radio_a_02" name="radio_a" />
<label for="radio_a_02"><span style="display:inline-block">暗夜蓝</span></label>
<i></i>
</li>
<li class="c">
<input type="radio" id="radio_a_03" name="radio_a" />
<label for="radio_a_03"><span style="display:inline-block">绯玉红</span></label>
<i></i>
</li>
</ul>
</div>
<script src="../js/checkedborder.js"></script>
<div id="radio_wrap">
<span class="GoodsInformation_reight-dt" style="display:inline-block;font-weight:700;margin-top:5px">机身分类</span>
<ul >
<li class="c checked">
<input type="radio" id="radio_a_04" name="radio_a" />
<label for="radio_a_01"><span style="display:inline-block">海风青</span></label>
<i></i>
</li>
<li class="c">
<input type="radio" id="radio_a_05" name="radio_a" />
<label for="radio_a_02"><span style="display:inline-block">暗夜蓝</span></label>
<i></i>
</li>
<li class="c">
<input type="radio" id="radio_a_06" name="radio_a" />
<label for="radio_a_03"><span style="display:inline-block">绯玉红</span></label>
<i></i>
</li>
</ul>
</div>
<script src="../js/checkedborder.js"></script>