jquery를 사용하여 다음 삭제 확인 코드가 있습니다. 문제는 이름 열의 위치를 가정한다는 것입니다. 이제 첫 번째 행에 이름이 있습니다. .prev('td')
을 사용하는 대신, jQuery를 사용하여 현재 행의 첫 번째 열에서 값을 가져 오는 것이 있습니까? 당신은 각jQuery를 사용하여 html 테이블에서 현재 행의 첫 번째 열 값을 얻는 방법
var name = $(this).parents('tr:first').find('td:first').text();
이 아래에 사용할 수
<script type='text/javascript'>
$(document).ready(function() {
$("a.delete").click(function(e) {
e.preventDefault();
var url = $(this).attr("href");
var name = $(this).parent().prev('td').prev('td').text();
jConfirm('Are you sure you want to delete this:' + name, 'Application Delete', function(r) {
if (r) {
window.location = url;
}
});
});
});
</script>
http://stackoverflow.com/questions/10796559/jquery-get-first-column-value-on-fourth-row-only-of-html-table – Lijo