2014-10-28 2 views
1

그물 전체를 검색했지만 내 코드가 구체적이라고 생각합니다 ... 단순히 행을 선택하고 클릭 한 행의 값을 가져오고 싶습니다 ... 여러 가지를 tryed했지만 none으로 설정했습니다. 일한 사람이 좀 도와 줄 수 있니? 임DataGrid 행 값 가져 오기

$('#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"); 
    }); 
    }); 

답변

0
$('#dataTable td').click(function(){ 
    //alert($(this).attr('nome')); //trying to alert id of the clicked row   
    window.alert($(this).val()); 
}); 

이것은 무엇을 말하는가? 그리고 당신은 jsfidlle을 만들 수 있습니까? jsfille에서 jquery에 의해 생성 된 테이블을 사용하십시오. 그래서 데이터베이스 연결이 아닌 HTML을 붙여 넣기 만하면됩니다.

관련 문제