Skip to Content
Learning jQuery - Fourth Edition
book

Learning jQuery - Fourth Edition

by Jonathan Chaffer, Karl Swedberg
June 2013
Beginner content levelBeginner
444 pages
9h 45m
English
Packt Publishing
Content preview from Learning jQuery - Fourth Edition

Using HTML5 custom data attributes

So far, we've been relying on the content within the table cells to determine the sort order. While we've managed to sort the rows correctly by manipulating that content, we can make our code more efficient by outputting more HTML from the server in the form of HTML5 data-* attributes. The second table in our example page includes these attributes:

<table id="t-2" class="sortable"> <thead> <tr> <th></th> <th data-sort='{"key":"title"}'>Title</th> <th data-sort='{"key":"authors"}'>Author(s)</th> <th data-sort='{"key":"publishedYM"}'>Publish Date</th> <th data-sort='{"key":"price"}'>Price</th> </tr> </thead> <tbody> <tr data-book='{"img":"2862_OS.jpg", "title":"DRUPAL 7","authors":"MERCER DAVID","published":"September ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning jQuery 3 - Fifth Edition

Learning jQuery 3 - Fifth Edition

Adam Boduch, Jonathan Chaffer, Karl Swedberg
jQuery Cookbook

jQuery Cookbook

Cody Lindley

Publisher Resources

ISBN: 9781782163145Other