Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8897467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:21:11+00:00 2026-06-15T00:21:11+00:00

I have html, and jquery for sorting my table (also there is non-standart sorting

  • 0

I have html, and jquery for sorting my table (also there is non-standart sorting (with multi-tbody)).

jQuery(function($) {
    var table = $('table');
    $(document).ready(function() {
        on_loaded($('.prcol'));
        $('.prcol').click(function(e) {
            on_loaded(this);
            e.preventDefault();
        });
    });

    function on_loaded(met) {
        var $sort = met;
        var $table = $('#articles-table');
        var $rows = $('tbody.analogs_art > tr', $table);
        $rows.sort(function(a, b) {
            var keyA = $('td:eq(3)', a).text().toUpperCase();;
            var keyB = $('td:eq(3)', b).text().toUpperCase();;

            if (keyA.length > 0 && isNaN(parseFloat($('td:eq(3)', b).text()))) return Ascending(keyA, keyB);
        });
        $.each($rows, function(index, row) {
            //console.log(row);
            $table.append(row);
            //$("table.123").append(row);
        });
    }

});


function Ascending(a, b) {
    if (a > b) return -1;
    if (a < b) return 1;
    return 0;
}

My code could be found here: http://jsfiddle.net/hGCgX/2/

But why it is sorting only in webkit browser’s? In ff and ie and opera i see nothing change… But why? How to do cross-browser sorting of html table?
also don’t say me to use tablesorter, why you have so much tbodie’s etc…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:21:12+00:00Added an answer on June 15, 2026 at 12:21 am

    I got it to sort in Opera as follows :

    $(function(){
        var $table = $('#articles-table');
        var $tbody = $('tbody.analogs_art', $table);
        var $rows = $tbody.children("tr");
    
        function on_loaded() {
            Array.prototype.sort.call($rows, function(a, b) {
                var keyA = Number($('td', a).eq(3).text()) || 0;
                var keyB = Number($('td', b).eq(3).text()) || 0;
                return keyB - keyA;
            });
            $.each($rows, function(index, row) {
                $tbody.append(row);
            });
        };
        $table.find("th").eq(3).on('click', function() {
            on_loaded();
        });
    });
    

    See updated fiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have html, and jquery for sorting my table (also there is non-standart sorting
I have an HTML table that I'm sorting with jQuery tablesorter. I have an
I have the following html code with Jquery Sorting <div class=sortable style='width:700px; margin: 0
I am using James Padolsey's jQuery sorting script for a HTML table in an
I have some html and jQuery code as follows: $(function(){ $(#button).click(function(e){ $('.imgdiv').load('images3.php'); e.preventDefault(); });
I have following code (html,js,jquery) snippet ( http://jsfiddle.net/MUScJ/2/ ): <script type=text/javascript> function someFunc(){ html
I have a html jquery mobile multi-page and using swipeleft and swiperight events to
I have the following jQuery: $.fn.dataTableExt.afnSortData['dom-text'] = function (oSettings, iColumn) { var aData =
I have HTML which includes scripts in following order <script src=../static/js/jquery.js type=text/javascript> <script src=../static/js/bootstrap.js
I have the following HTML on a Jquery Mobile Page: <div data-role=controlgroup data-type=horizontal class=panelSwitcher>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.