Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialYoung Choe
Python Web Development Techdegree Student 6,259 PointsPagination Function is not working with Jquery
This is the snapshot of the HTML and CSS files.
function pagination(totalStudentsToSort) {
const paginationNav = document.querySelector('.pagination ul');
let totalPages = Math.ceil(totalStudentsToSort / 10);
let paginationHTML = $();
for (let i = 1; i <= totalPages; i++) {
if (i === 1) {
$(paginationHTML).html("<li> + <a class=\"active\" href=\"#\"> + i + </a> + </li>");
} else {
$(paginationHTML).html("<li> + <a href=\"#\"> + i + </a> + </li>");
}
}
$(paginationNav).html(paginationHTML);
}
This is the function that is causing the page buttons to not show up in the browser.
1 Answer
Steven Parker
231,275 PointsWhy isn't the JavaScript included in the snapshot?
But a few issues stand out at first glance:
- the code defines a function but never calls it
- the function tries to select an element that does not exist in the HTML
- the function also attempts to add HTML content to an empty jQuery object set
Young Choe
Python Web Development Techdegree Student 6,259 PointsYoung Choe
Python Web Development Techdegree Student 6,259 PointsMy bad here is the javascript file with the snapshot. https://w.trhou.se/mz5yyuklbx. I
Steven Parker
231,275 PointsSteven Parker
231,275 PointsThere are a number of issues, here's a few hints to get you started: