有一个形式的收音机,我用jquery和css打扮。现在我想对它做更多的jquery但是当我运行两个代码时,一旦选择了无线电,li就不会关闭。一旦你点击收音机位,李应该关闭。 aslo需要告诉它执行以下操作:使用input = name“radio_selected”获取无线电选择的无线电交换。这样隐藏的li中所选的收音机将移出隐藏的li并交换位置,而不会隐藏在页面上。
$("input[name='domain_ext']").each(function() {
$("#radio_select").attr('checked', 'checked');
var lbl = $(this).parent("label").text();
if ($(this).prop('checked')) {
$(this).hide();
$(this).after("<div class='radioButtonOn'>" + lbl + "</div>");
} else {
$(this).hide();
$(this).after("<div class='radioButtonOff'>" + lbl + "</div>");
}
});
$("input[type=radio]").change(function() {
$(this).siblings('.radioButtonOff').add('.radioButtonOn').toggleClass('radioButtonOff radioButtonOn');
});
$('div.ribbonBoxarrow').click(function() {
$('.ribbonBoxarrow li').show('medium');
return false;
});
// once you leave the div (which is contained in the above li hide.
$('.ribbonBoxtab').mouseleave(function() {
$('.ribbonBoxarrow li').hide('slow'); //missing .
return false;
});
//if a radio buttn is clicked the hide li
$("input[name='domain_ext']").click(function() { //changed .each to .click
$('.ribbonBoxarrow li').hide('slow'); //missing .
return false;
});
答案 0 :(得分:1)
$("input[name='domain_ext']").each(function() {
$("#radio_select").attr('checked', 'checked');
var lbl = $(this).parent("label").text();
if ($(this).prop('checked')) {
$(this).hide();
$(this).after("<div class='radioButtonOn'>" + lbl + "</div>");
} else {
$(this).hide();
$(this).after("<div class='radioButtonOff'>" + lbl + "</div>");
}
});
$("input[type=radio]").change(function() {
$(this).siblings('.radioButtonOff').add('.radioButtonOn').toggleClass('radioButtonOff radioButtonOn');
});
$('div.ribbonBoxarrow').click(function() {
$('.ribbonBoxarrow li').show('medium');
return false;
});
// once you leave the div (which is contained in the above li hide.
$('.ribbonBoxtab').mouseleave(function() {
$('.ribbonBoxarrow li').hide('slow'); //missing .
return false;
});
//if a radio buttn is clicked the hide li
$("input[name='domain_ext']").parent('label').click(function() { //changed .each to .click
$('.ribbonBoxarrow li').hide('slow'); //missing .
return false;
});