2013-05-16 6 views
2

i 데이터 테이블 생성을 위해 datatables 클래스를 사용하는 datatable.i에 대한 간단한 contexMenu를 작성합니다. 각 테이블을 오른쪽 클릭하여 테이블의 첫 번째 셀을 찾고 싶습니다. 어떻게 찾을 수 있습니까? 내 영어 JQuery와 죄송jQuery는 테이블의 첫 번째 셀을 찾습니다.

:

$("#showTopics tbody").bind("contextmenu",function(event) { 
     var aata = $(this).children('tr').children('td').eq(0).text(); 
     alert(aata); 
    return false; 
}); 

HTML은

<table id='showTopics' style='line-height:18px;'> 
    <thead> 
     <tr> 
      <th style='width:30%;text-align:right;'>X"</th> 
      <th style='width:7%;'>a</th> 
      <th style='width:12%;'>b</th> 
      <th style='width:11%;'>c</th> 
      <th style='width:9%;'>d</th> 
     </tr> 
    </thead> 
    <tbody> 
    </tbody> 
</table> 

답변

0

이 나를 위해 작동합니다. 바이올린 : http://jsfiddle.net/FaRSa/ 그러나 귀하의 예제에서 당신은 $("#showTopics tbody"). 에서 이벤트를 넣어 그리고 당신의 HTML은 내가 TBODY 다른 TR에 던져 기능이 잘 작동 바이올린에서 thead

의 내용을 보여줍니다. :)

+0

그래 내가 그럴 handly을 만들고 난 –

0

이 시도 :

$("#showTopics tr").bind("contextmenu",function(event) { 
    var aata = $(this).children().siblings(':first').text(); 
    alert(aata); 
    return false; 
}); 
+0

정확하지이 코드를 데이터를 생성하기위한 datatables에게 클래스를 사용하고 그 일 :( –

관련 문제