Search code examples
javascriptjquerytablesorter

Filter table by letter


I want to sort a table with one column by beginning letter. So if I click e.g. button 'e' the page should only show entries beginning with an 'e'.


Solution

  • Assuming you have an array with your data, you can use javascript filter function. Something like:

    var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
    const result = words.filter(word => word.charAt(0) == 'e');