Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
Filtro múltiple para una tabla específica

Tengo este código funcionando para cualquier tabla.

 $(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(); }); } });

Filtra bien, el problema que tengo es con una mesa especial que no funciona. Tengo el ID de la tabla pero no sé cómo implementar el código para que funcione exclusivamente para este ID de tabla. Intenté modificar este filter('#TABLEID > tbody > tr', values); pero no funciona.

Objetivo: modificar el código para que funcione solo con una tabla específica (específicamente una con ID posts-table-1, vea jsfiddle a continuación), porque el código, que supuestamente funciona para cualquier tabla, no funciona

Aquí hay un ejemplo: https://jsfiddle.net/mdomfu/gzLktpmw/3/

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!