검색 필드가있는 테이블이 있습니다. 데이터를 검색 한 후 나열된 데이터를 Excel로 내보내고 테이블에 표시되지 않은 추가 정보가 필요하며 데이터베이스에서 가져와야합니다. 따라서 나열된 모든 데이터의 ID에 액세스해야합니다 (검색 후). 또한 태그에는 데이터 테이블을 사용하여 렌더링되었으므로 잡을 수 있도록 관련 'id'또는 'class'가 없습니다. jquery를 사용하여 어떻게 얻을 수 있습니까?
<table id='mytable' border='1'>
<tr>
<th id='ID'>ID</th>
<th id='Email'>Email</th>
</tr>
<tr>
<td>1</td>
<td>[email protected]</td>
</tr>
<tr>
<td>2</td>
<td>[email protected]</td>
</tr>
<tr>
<td>3</td>
<td>[email protected]</td>
</tr>
</table>
<button id='gen'>Generate excel file</button>
jsfiddle : http://jsfiddle.net/xLA3g/2/
이것 좀 봐, 도움이 될까요 http://jsfiddle.net/xLA3g/3/
$('#mytable tr th').each(function(i){
alert($(this).text());
});
답변 업데이트 , td 열 번호 표시 http://jsfiddle.net/xLA3g/4/
$('#mytable tr td:first-child').each(function(i){
alert($(this).text());
});
도움이 더 필요하면 알려주세요.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다