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]
来检查表中选定的行。下面的代码使用的是HTML5和JQuery 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);
});
});