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]"> ...
Coding Cheatsheets - Learn web development code and tutorials for Software developers which will helps you in project. Get help on JavaScript, PHP, XML, and more.