0

Below are my codes I'm using currently. Can someone help as this is important.

$("#btn" + arr[i].numberID).on("click", { id: arr[i].numberID }, function (event) {
  var data = event.data;
  getdet(data.id);
});

function getdet(numberID) {
  window.location = "order.html?numberID=" + numberID;
}
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Hrz
  • 11
  • 2

1 Answers1

0

I am not sure about this, but I think your issue is that the click event listener is not binding to the buttons in the other pages(the reason being that the buttons are dynamically generated when you change pages).
This article explains the problem: Event binding on dynamically created elements?.
Try if this works:

$(document).on("click", "#btn" + arr[i].numberID, { id: arr[i].numberID }, function (event) {
  var data = event.data;
  getdet(data.id);
});

function getdet(numberID) {
  window.location = "order.html?numberID=" + numberID;
}

Hope this helps.

NiK648
  • 1,484
  • 1
  • 9
  • 18