Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML Jquery单选按钮根据选择进行切换_Javascript_Html_Jquery_Css_Radio Button - Fatal编程技术网

Javascript HTML Jquery单选按钮根据选择进行切换

Javascript HTML Jquery单选按钮根据选择进行切换,javascript,html,jquery,css,radio-button,Javascript,Html,Jquery,Css,Radio Button,我有两个单选按钮可以打开选定的。选择两个单选按钮中的一个时,应有相应的说明;选择另一个时,说明应更改 下面的代码基本上实现了我想要的功能,但问题是它只需单击即可实现。其中一个单选按钮是预选的(带有“checked”属性),在用户单击单选按钮之前不会显示说明。因此,如果预先选中其中一个单选按钮,我希望说明与相应的单选按钮匹配 $(文档).ready(函数(){ $('input[name=“subscription type”]”)。单击(函数(){ var inputValue=$(this.

我有两个单选按钮可以打开选定的。选择两个单选按钮中的一个时,应有相应的说明;选择另一个时,说明应更改

下面的代码基本上实现了我想要的功能,但问题是它只需单击即可实现。其中一个单选按钮是预选的(带有“checked”属性),在用户单击单选按钮之前不会显示说明。因此,如果预先选中其中一个单选按钮,我希望说明与相应的单选按钮匹配

$(文档).ready(函数(){
$('input[name=“subscription type”]”)。单击(函数(){
var inputValue=$(this.attr(“值”);
变量targetBox=$(“+inputValue);
$(“.subscription desc”).not(targetBox.hide();
$(targetBox.show();
});
});
.subscription desc{
显示:无;
}

经典
冒险者
说明1
说明2

您可以触发
。单击
:checked
单选按钮上的
事件,以便触发单击事件:

$('input[name="subscription-type"]:checked').click();
$(文档).ready(函数(){
$('input[name=“subscription type”]”)。单击(函数(){
var inputValue=$(this.attr(“值”);
变量targetBox=$(“+inputValue);
$(“.subscription desc”).not(targetBox.hide();
$(targetBox.show();
});
$('input[name=“subscription type”]:选中')。单击();
});
.subscription desc{
显示:无;
}

经典
冒险者
说明1
说明2

您可以触发
。单击
:checked
单选按钮上的
事件,以便触发单击事件:

$('input[name="subscription-type"]:checked').click();
$(文档).ready(函数(){
$('input[name=“subscription type”]”)。单击(函数(){
var inputValue=$(this.attr(“值”);
变量targetBox=$(“+inputValue);
$(“.subscription desc”).not(targetBox.hide();
$(targetBox.show();
});
$('input[name=“subscription type”]:选中')。单击();
});
.subscription desc{
显示:无;
}

经典
冒险者
说明1
说明2