Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.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

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 HTML5 tr,带无线电行选择_Javascript_Jquery_Html - Fatal编程技术网

Javascript HTML5 tr,带无线电行选择

Javascript HTML5 tr,带无线电行选择,javascript,jquery,html,Javascript,Jquery,Html,从下面的代码中,我无法使用输入[radio]来检查表中选定的行。下面的代码使用的是HTML5和JQuery 1.10.2 <!DOCTYPE HTML> <html> <head> <style type="text/css"> input[type="radio"] { margin: 10px; } </style>

从下面的代码中,我无法使用
输入[radio]
来检查表中选定的行。下面的代码使用的是HTML5JQuery 1.10.2

<!DOCTYPE HTML>
<html>
    <head>
        <style type="text/css">
            input[type="radio"] {
                margin: 10px;
            }
        </style>
        <script src="jquery-1.10.2.min.js" />
        <script>            
            $(function() {
                $("#table_list tr").click(function() {
                    $(this).find("td input:radio").prop("checked", true);
                });
            });
        </script>
    </head>
    <body>
        <table id="table_list">
            <thead>
                <th></th>
                <th>Name</th>
                <th>Email</th>              
            </thead>
            <tbody>
                <tr>
                    <td><input type="radio" name="record"/></th>
                    <td>Sample1</td>
                    <td>sample_1@sample.com</td>
                </tr>
                <tr>
                    <th><input type="radio" name="record"/></th>
                    <td>Sample1</td>
                    <td>sample_1@sample.com</td>                    
                </tr>
            </tbody>
        </table>        
    </body>
</html>

输入[type=“radio”]{
利润率:10px;
}
$(函数(){
$(“#表格列表tr”)。单击(函数(){
$(this).find(“td输入:无线电”).prop(“选中”,true);
});
});
名称
电子邮件
样本1
样品_1@sample.com
样本1
样品_1@sample.com                    

您的第一个输入位于
td
中,第二个输入位于
th
中。您必须从输入选择器中删除
td

附加的javascript将适用于这两种情况。。另一种选择是将
th
更改为
td
,并保持选择器原来的状态


注意:您还有一些注释中提到的标记问题。(忘记
tr
thead
中)

您的第一个输入在
td
中,第二个输入在
th
中。您必须从输入选择器中删除
td

附加的javascript将适用于这两种情况。。另一种选择是将
th
更改为
td
,并保持选择器原来的状态

注意:您还有一些注释中提到的标记问题。(忘记了
tr
thead

请看

请看一看


你能提供一个JSFIDLE吗?首先,你需要为你的收音机添加一个值,以便以后对其进行评估。修复你的标记,它就会工作(你在
中有
和其他
标记,而且你的
没有
)html,你能提供一个JSFIDLE吗?首先,您需要为您的收音机设置一个值,以便以后对其进行评估。修复您的标记,它就会工作(您在
中有
和其他
标记,并且您的
没有
html固定在此处)
$(function() {
    $("#table_list tr").click(function() {
        $(this).find("input:radio").prop("checked", true);
    });
});
$(document).ready(function(){
  $('#table_list tr').on("click",function(){
$(this).find('input[type=radio]').prop("checked", true);
  });
});