Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.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 获取Jquery中所选单选按钮的ID;名称有[]个“;_Javascript_Jquery_Html_Radio Button_Brackets - Fatal编程技术网

Javascript 获取Jquery中所选单选按钮的ID;名称有[]个“;

Javascript 获取Jquery中所选单选按钮的ID;名称有[]个“;,javascript,jquery,html,radio-button,brackets,Javascript,Jquery,Html,Radio Button,Brackets,我正在使用一个在线产品,出于某种原因,当它生成有问题的页面时,单选按钮集的名称是product_id_page-0[]您需要用两个斜杠替换元字符: var userType =$('#product_id_page-0\\[\\]:radio:checked').attr('id'); alert("xmlvalue is: " + userType); 如果这是名称而不是id,请使用: var userType =$('[name=product_id_page-0\\[\\]]:r

我正在使用一个在线产品,出于某种原因,当它生成有问题的页面时,单选按钮集的名称是product_id_page-0[]您需要用两个斜杠替换元字符:

var userType =$('#product_id_page-0\\[\\]:radio:checked').attr('id');
    alert("xmlvalue is: " + userType);
如果这是名称而不是id,请使用:

var userType =$('[name=product_id_page-0\\[\\]]:radio:checked').attr('id');
        alert("xmlvalue is: " + userType);

根据您的示例,您使用的是元素ID,而不是名称。
var userType =$('#product_id_page-0\\[\\]:radio:checked').attr('id');
    alert("xmlvalue is: " + userType);
var userType =$('[name=product_id_page-0\\[\\]]:radio:checked').attr('id');
        alert("xmlvalue is: " + userType);