用jquery写,多组radio,换radio选中时的样式,结果全都选中了
$(document).ready(function(){$(".user-list").each(function(i,element){$("input:radio[...
$(document).ready(function() {$(".user-list").each(function(i,element){ $("input:radio[name='ra"+ i +"']").bind('change',function (){ $("input:radio:not([checked])").parent().attr("class",""); $("input:radio:checked").parent().attr("class","on"); })})})
这是html代码
<ul class='user-list'> <li>黄</li> <li>副总裁</li> <li><span><input type='radio' name='ra4'/></span></li> <li><span><input type='radio' name='ra4'/></span></li> <li><span><input type='radio' name='ra4'/></span></li> <li><span><input type='radio' name='ra4'/></span></li> <li><span><input type='radio' name='ra4'/></span></li> </ul> <ul class='user-list'> <li>黄</li> <li>副总裁</li> <li><span><input type='radio' name='ra5'/></span></li> <li><span><input type='radio' name='ra5'/></span></li> <li><span><input type='radio' name='ra5'/></span></li> <li><span><input type='radio' name='ra5'/></span></li> <li><span><input type='radio' name='ra5'/></span></li> </ul>
结果点击一个,2块的都选中了 展开
这是html代码
<ul class='user-list'> <li>黄</li> <li>副总裁</li> <li><span><input type='radio' name='ra4'/></span></li> <li><span><input type='radio' name='ra4'/></span></li> <li><span><input type='radio' name='ra4'/></span></li> <li><span><input type='radio' name='ra4'/></span></li> <li><span><input type='radio' name='ra4'/></span></li> </ul> <ul class='user-list'> <li>黄</li> <li>副总裁</li> <li><span><input type='radio' name='ra5'/></span></li> <li><span><input type='radio' name='ra5'/></span></li> <li><span><input type='radio' name='ra5'/></span></li> <li><span><input type='radio' name='ra5'/></span></li> <li><span><input type='radio' name='ra5'/></span></li> </ul>
结果点击一个,2块的都选中了 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询