Jquery 获取datagrid行值
我搜索了整个网络,但我认为我的代码是特定的…我只想简单地选择行并从我单击的行中获取值…我尝试了几件事,但都没有成功。。有人能帮我一点忙吗?我正在尝试获取nome列的值Jquery 获取datagrid行值,jquery,html,datagrid,Jquery,Html,Datagrid,我搜索了整个网络,但我认为我的代码是特定的…我只想简单地选择行并从我单击的行中获取值…我尝试了几件事,但都没有成功。。有人能帮我一点忙吗?我正在尝试获取nome列的值 $('#dataTable tbody').click(function (event) { //alert($(this).attr('nome')); //trying to alert id of the clicked row }); 我的桌子是: <table id="dataTab
$('#dataTable tbody').click(function (event) {
//alert($(this).attr('nome')); //trying to alert id of the clicked row
});
我的桌子是:
<table id="dataTable" class="datagrid">
<thead class="tabela1">
<th field="nome" class="tabela1">Nome</th>
<th field="senha" class="tabela1">Senha</th>
<th field="telefone" class="tabela1">Telefone</th>
<th field="email" class="tabela1">Email</th>
</thead>
<tbody class="tabela1"></tbody>
</table>
但我正在使用jquery代码填充表格:
$(document).ready(function(){
var url;
var url_save="save_users.php";
$("#dataTable tbody").html("");
$.getJSON("get_users.php",function(data){
$.each(data.users, function(i,user){
var newRow =
"<tr>"
+"<td>"+user.nome+"</td>"
+"<td>"+user.senha+"</td>"
+"<td>"+user.telefone+"</td>"
+"<td>"+user.email+"</td>"
+"</tr>" ;
$(newRow).appendTo("#dataTable tbody");
});
});
这是怎么说的?你能做一个jsfidle吗?在jsfille中,使用jquery生成的表。所以只需将HTML粘贴到其中,而不是数据库连接,因为这对我们没有帮助
$('#dataTable td').click(function(){
//alert($(this).attr('nome')); //trying to alert id of the clicked row
window.alert($(this).val());
});