jQuery cannot catch the DataTable button class in Laravel

40 Views Asked by At

The button in td is from the DataTable Ajax back data:

<button type="button" class="btn btn-default downpraise " data-toggle="tooltip"  data-placement="top" title="downbutton" name="downtest">
      <i class="far fa-thumbs-down">data</i>
</button>

My funtion is:

$('button[name="downtest"]').on('click',function(){
    console.log("downbutton push1);
})

or

$(".downpraise").on('click', function() {
    console.log("downbutton push2);
})

The above two do not get any responses? Any clues?

PS:

columns: [
          { data: 'action',  render: function ( data ) {              

        return  '<button type="button" class="btn btn-default downpraise " data-toggle="tooltip"  data-placement="top" title="downbutton" name="downtest">
             <i class="far fa-thumbs-down">data</i>
       </button>'
  ]
1

There are 1 best solutions below

0
robspin On BEST ANSWER

I solve the question by

$(document).on( 'click', 'button.downpraise', function () {
}

I don't know why the original method cannot work.