我有几个使用图像作为屏幕显示的单选按钮。常规状态、悬停状态和单击状态。图像显示在每个州,但如果我点击 2 单选按钮,两者都保持点击状态。我怎么能有它,或者点击时。
这是jQuery:
$(".image_radiobtn input[type='radio']").change(function(){
if($(this).is(":checked")){
$(this).next("label").removeClass('hover').addClass('checked');
}
else{
$(this).next("label").removeClass('checked');
}
});
这是html:
<ul id="radiobtn-toggle-view" class="image_radiobtn">
<li>
<input id="input-1" type="radio" name="address" value="1" />
<label for="input-1">Use this address.</label>
</li>
</ul>
这是CSS:
#radiobtn-toggle-view, #radiobtn-toggle-view2 {
list-style: none;
margin: 0;
position: relative;
cursor: pointer;
}
#radiobtn-toggle-view li, #radiobtn-toggle-view2 li{
min-height: 15px;
height: 15px;
margin:0;
padding: 10px 0;
}
#radiobtn-toggle-view label, #radiobtn-toggle-view2 label {
cursor: pointer;
font-size: 14px;
font-weight: bold;
height: 15px;
line-height: 15px;
margin: 0;
text-decoration: none;
}
.image_radiobtn li input[type='radio']{
display:none;
}
.image_radiobtn li label {
background: url(/images/icons/grey_radio_btn.png) no-repeat;
padding-left: 20px;
}
.image_radiobtn li label:hover {
background: url(/images/icons/e_radio_btn.png) no-repeat;
}
.image_radiobtn li label.checked {
background: url(/images/icons/g_radio_btn.png) no-repeat;
}
.hidden {display: none;}