내 HTML 문서에서 문서가 완전히로드되면 jQuery에 의해 자동으로 채워지는 빈 표 본문이있는 표가 있습니다. 테이블 본문은 PHP 스크립트에 의해 생성되며 jQuery는 간단한 GET 요청으로 컨텐츠를 가져옵니다. 여기jQuery 선택이 작동하지 않습니다.
내 PHP 코드는 ...
<?php
// ...
// ...
// Just take a look at the following two lines,
// the other code is not important in this case.
while ($tableDataRow = $tableData->fetch_assoc())
echo '<tr><td>'. $tableDataRow['id']. '</td><td>'. $tableDataRow['name']. '</td><td><a href="#" class="delete-row" data-id="'. $tableDataRow['id']. '">Delete</a></td></tr>';
?>
가 출력이 될 수 ...
<tr><td>1</td><td>Nadine</td><td><a href="#" class="delete-row" data-id="1">Delete</a></td></tr><tr><td>2</td><td>Nicole</td><td><a href="#" class="delete-row" data-id="2">Delete</a></td></tr>
모든 것이 완벽하게 작동, 유일한 문제는 jQuery를 어떤 클릭 이벤트 경우 반응하지 않는다는 것입니다 발생합니다. 내 jQuery 코드는 ... 다음과 같습니다
$(document).ready(function() {
$(".delete-row").click(function(event) { // "a[class=delete-row]" does not work, too. But "*" works for every element, even for the links?!
event.preventDefault();
alert("You clicked on that link!")
});
});
'$ ('body '). on ('클릭 ','.delete-row ', function (이벤트) {...});' – FSou1
키워드 기능을 잘못 사용했습니다. –