This is not know at the time of learning problems, recorded for easy viewing
Go https://www.cnblogs.com/mr-wuxiansheng/p/7136864.html
// Bind the next page click event $ ( "A [Aria-label = 'the Next']"). The Click (function () { $ ( "A [Aria-label = 'Previous']"). Show ( ); IF (page.pageNo page.totalPage == -. 1) { $ ( "A [Aria-label = 'the Next']") hide ();. } the else { $ ( "A [Aria-label = 'the Next '] ") Show ();. } page.pageNo ++; page.pageSet (BindData, Page); }); // above .click () to bind click event and the following $ (document) .on (" click "," pagination li: gt ( 0): not. (: last) ", function () {}); the difference is that: // .click only bind the click event to an existing page elements, if it is dynamic generate new elements, there is no event //The $ (document) .on ( "click ", " specified element", function () {}) ; sucked method specified event bound to the document,
the elements // newly generated if they meet specified element ,
// it would trigger this event // add page numbers dynamically generated button click event $ (document) .on ( "click ", "pagination li:. gt (0): not (: last)", function () { page.pageNo = $ (the this) .text (); . $ ( "A [Aria-label = 'the Previous']") Show (); $ ( "A [Aria-label = 'the Next']"). Show (); IF (page.pageNo == ". 1") { $ ( "A [Aria-label = 'the Previous']") hide ();. } IF (page.pageNo == page.totalPage) { $ ( "a [aria-label = 'Next']") hide ().; } page.pageSet(bindData , page); });
Conclusion:
Difference; above .click () and bind click event below $ (document) .on (, function () {} "click", "last). Pagination li: gt (0):: not (") that:
(1) .click only be bound to an existing page element click event, if it is dynamically generated new elements, there is no event of
(2) and $ (document) .on ( "click ", " designated elements ", function () {}) ; sucked method specified in the event binding document, and the element newly generated if they meet specified element, it would trigger this event