0

I cannot understand why I can't select a group of buttons with Jquery.

This is my HTML (The tbody is built on an ajax call) on the page load.

    <table class="table table-hover" id="tblGroup">
      <thead>
        <tr>
          <th>Groups</th>
        </tr>
      </thead>
      <tbody>
       <tr>
       <td>xxx123</td>
       <td><button class="btn btn-info delete" type="button" value="xxx123">Delete</button><button class="btn btn-info view" type="button" value="xxx123">View</button></td></tr>
       // more and more rows omitted
      </tbody>
    </table>

I'm my javascript file I have (which is placed in document.ready):

$("#tblGroup tbody .view").on("click", function () {
    alert("view");
});

I do not see the alert when I click the view button.

However if I type from the console

$("#tblGroup tbody .view")

It will find all of the buttons.

I'm at a total loss why my button click event won't work.

John Doe
  • 3,053
  • 17
  • 48
  • 75

0 Answers0