Skip to main content

Posts

Showing posts with the label jquery table sort

Sort Table by jquery

1.  Sort table first column by jQuery Create a function sortTable. Pass table id & order function sortTable(table, order) {             var asc   = order === 'asc',             tbody = table.find('tbody');          tbody.find('tr').sort(function(a, b) {         if (asc) {             return $('td:first', a).text().localeCompare($('td:first', b).text());         } else {             return $('td:first', b).text().localeCompare($('td:first', a).text());         }     }).appendTo(tbody); } Call function when document loaded jQuery(document).ready(function() { sortTable($('#editable'),'asc'); }); 2. Sort the select option without empty value Html: <select id="contacts" class="filteroption" name="data[Candidateprofile][company]"> ...