Last active
October 26, 2021 08:15
-
-
Save PhongGCS/178fbcb40b6e926718129b072ec6bf03 to your computer and use it in GitHub Desktop.
Pagination ajax for wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pagination(url) { | |
let html = jQuery.get(url) | |
html.done( (res) => { | |
let elements = jQuery(res); | |
let found = jQuery('#main', elements); | |
let child = found.children(); | |
jQuery('#main').empty(); | |
jQuery('#main').append(child) | |
}); | |
} | |
jQuery("a.page-number").on("click", (event) => { | |
event.preventDefault(); | |
let target = event.target; | |
url = jQuery(target).attr("href"); | |
pagination(url) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment