Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
Multiple filter for an especific table

I have this code working for any table.

$(document).ready(function () {  
  $('.CalendarFilter').click(function () {
        var values = [];

         $('.filter').each(function () {
            var colIdx = $(this).data('col');

             $(this).find('option:selected').each(function () {
                 if ($(this).val() != "") values.push( {
                    text: $(this).text(),
                    colId : colIdx
                 });
            });
        });
        filter('table > tbody > tr', values);
    });

    function filter(selector, values) {console.log(values);
        $(selector).each(function () {
            var sel = $(this);
            var tokens = sel.text().trim().split('\n');
            var toknesObj = [], i;
            for(i=0;i<tokens.length;i++){
                toknesObj[i] = {
                   text:tokens[i].trim(), 
                   found:false
                };
            }

            var show = false;
            //console.log(toknesObj);
            $.each(values, function (i, val) {                

           if (toknesObj[val.colId].text.search(new RegExp("\\b"+val.text+"\\b")) >= 0) {
               toknesObj[val.colId].found = true;
              }

            });          
            console.log(toknesObj);
            var count = 0;
             $.each(toknesObj, function (i, val) {
                 if (val.found){
                     count+=1;
                 }
             });
            show = (count === values.length);        
            show ? sel.show() : sel.hide();
        });
    }
    });

It filters good, the problem I have is with an special table that is not working. I have the ID of the table but I don't know how to implement the code for work exclusively for this table ID. I tried modifying this part filter('#TABLEID > tbody > tr', values); but is nor working.

Goal: modify the code to work only with an specific table (specifically one with ID posts-table-1, see jsfiddle below), because the code, which supposedly works for any table, doesn't work

Here is an example: https://jsfiddle.net/mdomfu/gzLktpmw/3/

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda