Geeks With Blogs
Ben Adler's Development Posting solutions as I find them

Often times sites will have horizontal menus created with tables. You can easily sort the cells by the containing links using jquery:

sortTD($("#topNav table tr"));


function sortTD(selector) {

    $(selector).children("td").sort(function (a, b) {

        var upA = $(a).children("a").text().toUpperCase();

        var upB = $(b).children("a").text().toUpperCase();

        return (upA < upB) ? -1 : (upA > upB) ? 1 : 0;

    }).appendTo(selector);

}

Posted on Wednesday, July 30, 2014 12:02 PM | Back to top


Comments on this post: Sort table cells by child link

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © BenAdler | Powered by: GeeksWithBlogs.net