Jquery radio 改变选中行li样式

<div id="divExpress" class="body setting express">
                <ul>
                    <li class="focus"><div class="label"><i></i><span>选择</span></div><span class="strong"><input class="rbox" type="radio">快递(默认申通或圆通)</span><span class="strong w1">5元 /千克</span><span class="strong w2">全国大部分地区都可以到,性价比高,速度快</span></li>
                    <li><div class="label"><i></i><span>选择</span></div><span class="strong"><input class="rbox" type="radio">邮政EMS</span><span class="strong w1">免运费</span><span class="strong w2">全国各地都能到,但速度较慢,如果您的所在地没有快递请选择此项。</span></li>
                    <li><div class="label"><i></i><span>选择</span></div><span class="strong"><input class="rbox" type="radio">货到付款</span><span class="strong w1">20元 /千克</span><span class="strong w2">联邦快递上门送货,将现金准备好给快递员即可。</span></li>
                </ul>
            </div>

如果选中 改变<li class="focus"> 反正则移除

慕妹3242003
浏览 537回答 12
12回答

哈士奇WWW

$(document).ready(function () {            $("#divExpress").find(".rbox").each(function () {                $(this).click(function () {                    $(this).parent().parent().parent().children().removeClass("focus");                    $(this).parent().parent().toggleClass("focus", this.checked);                });            });        });   希望有用

小怪兽爱吃肉

$('#divExpress li').each(function(){ $(this).click(function(){ $('#divExpress li').removeClass('focus'); $(this).addClass('focus'); }); });

GCT1015

是选中里面的radio 改变样式

至尊宝的传说

@暗尘掩月:  $('.rbox').each(function(){ $(this).click(function(){ $('.rbox').removeClass('focus'); $(this).addClass('focus'); }); });

红糖糍粑

$('.rbox').each(function(){ $(this).click(function(){ $('.rbox').removeClass('focus'); $(this).addClass('focus'); }); });

慕后森

@田林九村: 不对啊 我是要选中radio 改变<li>标签的样式 移除其他航的样式

郎朗坤

@暗尘掩月: 不急不急,马上来 $('.rbox').each(function(){ $(this).click(function(){ $('#divExpress li').removeClass('focus'); $(this).parent().prev().prev().addClass('focus'); }); });

猛跑小猪

$('.rbox').each(function(){ $(this).click(function(){ $('#divExpress li').removeClass('focus'); $(this).parent().prev().prev().addClass('focus'); }); });

桃花长相依

@田林九村: 还是不对 麻烦先测试下啊 谢谢

慕的地10843

$(function () {            $(":radio").click(function () {                if (this.checked) {                    $(this).parent("span").parent("li").addClass("p");                }            });        });再修改修改吧!
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript