특정 클래스가있는 행에서 jquery 데이터 테이블의 데이터를 가져 오려고합니다.jquery 데이터 테이블의 모든 열을 반복하고 특정 클래스가있는 행에서 데이터를 가져옵니다.
내 테이블은 다음과 같습니다. 데이터 테이블에도 페이지 매김이 있습니다. 위의 코드에서
$('body').on('change', 'input.checked-box', function() {
if ($(this).prop('checked') == true) {
$(this).closest('tr').addClass('selectedRow');
}
else {
$(this).closest('tr').removeClass('selectedRow');
}
if (table.rows('.selectedRow').data().length > 0) {
$('#downloadDoc').removeClass('inactive');
$('#downloadDoc').addClass('active');
}
else {
$('#downloadDoc').removeClass('active');
$('#downloadDoc').addClass('inactive');
}
});
:
ID | DocumentID | FileName | |
------------------------------------------
1 | 201| abc.cc | check box|
제가 아래의 코드를 사용하여 일부 행에 클래스 추가 input.checked-box
은 체크 박스 <input type='checkbox' class='checked-box' id='check0'>
이며, 체크 박스는 특정 ID와 각 행에 추가 . 체크 박스를 클릭하면 해당 행에 class='selectedRow'
이 표시됩니다. 따라서 위 코드는 해당 확인란을 선택하면 각 행에 클래스를 추가합니다. 지금까지 잘 작동합니다. 이제
, 나는 버튼을 클릭했을 때 class='selectedRow'
이
내 HTML (<button id='downloadDoc' class='active'>
말할)이있는 행을 (위의 표에서와 같이) "DocumentID"컬럼의 데이터를 얻을 수있는 방법 :
<div class="table-responsive">
<button id='downloadDoc' class='inactive'>
<table id="attachmentList" class="display">
<thead>
<tr>
<th></th>
<th>Attachment Detail Id</th>
<th>File Name</th>
<th></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
무엇 귀하의 마크 업에서 해당 버튼의 위치는 무엇입니까 ?? –
@RajaprabhuAravindasamy와 동일한 'div'에있는 표가 있습니다. – Riki