如果选中,我正在尝试将一个 CSS 类添加到我的单选按钮的 div.from 中。如果未选中则删除。
和html:
<div style="width:49.5%;height:auto;float:left;" class="from">
<label>
<div class="fromm" id="order">
<div class="frairimg"></div>
<div class="frfromdetails"></div>
<div class="frarrow"></div>
<div class="frfromdetails"></div>
<div class="frrefund"></div>
<div class="radio"><input type="radio" name="from" id="something" class="getvalue"></div>
<div class="frfnumber"></div>
<div class="roundfare"></div>
</div>
</label>
<label>
<div class="fromm" id="order1">
<div class="frairimg"></div>
<div class="frfromdetails"></div>
<div class="frarrow"></div>
<div class="frfromdetails"></div>
<div class="frrefund"></div>
<div class="radio"><input type="radio" name="from" id="something1" class="getvalue"></div>
<div class="frfnumber"></div>
<div class="roundfare"></div>
</div>
</label>
<label>
<div class="fromm" id="order2">
<div class="frairimg"></div>
<div class="frfromdetails"></div>
<div class="frarrow"></div>
<div class="frfromdetails"></div>
<div class="frrefund"></div>
<div class="radio"><input type="radio" name="from" id="something2" class="getvalue"></div>
<div class="frfnumber"></div>
<div class="roundfare"></div>
</div>
</label>
</div>
CSS
<style>
.checked11 { background: red; }
</style>
这是我在jquery中提出的:
<script>
$(document).ready(function() {
$('input:radio').click(function() {
$('input:radio[name='+$(this).attr('name')+']').parent().removeClass('checked11');
$(this).parent().addClass('checked11');
});
});
</script>
这里我的问题是该类仅申请单选按钮,但希望它申请 div.from
谢谢你。纳雷什·卡米雷迪