1

以下のコードは、Ajax 呼び出しを使用して動的に生成され、studentresultsというハードコードされた div に配置されます。

<div id="studentresults" class="row span8 offset2">
  <table id="tablestudent" class="table table-striped table-hover center-table">
    <thead>Heading for my table</thead<
      <tbody>
        <tr id="showstudents">
          <td>29041</td>
          <td>jan</td>
          <td>jan</td>
          <td>
            <a class="btn" href="#">View Results »</a>
          </td>
          <td id="29041">
            <a id="29041" class="btn showstudent" href="#">Delete Student » </a>
          </td>
        </tr>
        <tr id="showstudents">
           .... another dynamic record from Ajax...
        </tr>
     </tbody>
  </table>
</div>

それはうまくいきます。ただし、生徒の削除タグで別の Ajax 呼び出しが必要です。この動的コンテンツの jQuery クリック関数の書き方がわかりません。

JQuery 呼び出しが機能しない

$('.showstudent').click(function(){

 alert('In click');

});

ただし、これはハードコードされた div で機能しますcontainer

 $('#studentresults').click(function () {

 alert('In click');

});

<a>動的コンテンツにアクセスするにはどうすればよいですか

4

1 に答える 1