I'm generating Bootstrap pagination element with PHP within a loop.
<button class="page-link" data-page="'.$page_number.'">'.$page_number.'</button>
The element is generated correctly:
<button class="page-link" data-page="1">1</button>
Then in my script, I need to get this data-page to pass in forward.
I'm trying to do this:
$('#taskcontainer').on("click", $(".page-link"), () => {
console.log($(this).data("page"));
})
But click on those buttons just gives me
undefined
I'm binding to #taskcontainer since this pagination elements are generated by PHP.