jQuery Collections Recap: Filter, Count & addClass on the Hire Desk
All lessons
- jQuery Collections Recap: Filter, Count & addClass on the Hire DeskFree
- $.ajax Anatomy: Settings, Status Codes, Timeouts & parsererror Locked
- $.getJSON and $.each: Rendering a JSON List into the Page Locked
- Promise Chains: .then Passes Values On, .done Does Not Locked
- Retrying Failed Requests with Exponential Back-off Locked
- $.when: Parallel Requests, the Slowest Wins, the First Failure Ends It Locked
- serialize() and serializeArray(): What a Form Really Sends Locked
- Live Form Validation: Reading Values, Trimming and Range Rules Locked
- Submitting Forms with AJAX: Blocking Double Submits Locked
- Event Delegation: One Handler for Rows That Do Not Exist Yet Locked
- Bubbling, Delegated Order and stopPropagation Locked
- Changing the DOM: append, remove, first() and Many Targets Locked
- Building Rows Efficiently: One Insert Instead of Hundreds Locked
- .data() vs .attr(): When jQuery Converts Your Numbers Locked
- $.map and $.each: Argument Order, Flattening and Breaking Out Locked
- Animation Timing: Durations, delay() and Parallel Elements Locked
- The Effects Queue: Why Menus Keep Bouncing, and stop() Locked
- .animate() and Easing: Where Is the Element at Time t? Locked
- Debouncing a Live AJAX Search Locked
- Final Project: The Live Hire-Desk Panel Locked
You are not signed in — the lab works, but your progress is not saved. Sign up
Read first
The code in this lab
// Kestrel Cycle Hire – hire desk: one <tr class="booking"> per booking
var NOW = 17; // current hour
var $rows = $('#bookings tr.booking');
var overdue = $rows
.filter('[data-status="open"]')
.filter(function () { return $(this).data('due') < NOW; })
.addClass('overdue');
var deposits = 0;
$rows.filter('.ebike').each(function () {
deposits += $(this).data('deposit');
});
$('#overdue-count').text(overdue.length);Loading the lab…