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

104
Vistas
Set Custom attribute in Js

I am filtering a table and exporting it to excel. To exclude the filtered rows, i have to set the data-exclude="true" in the 'tr'-element

function Search() {
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("myInput");
  filter = input.value.toUpperCase();
  table = document.getElementById("myTable");
  tr = table.getElementsByTagName("tr");
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[7];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "" ;
//Set here the Code data-exclude="false"
      } else {
        tr[i].style.display = "none";
//Set here the Code data-exclude="true";

      }
    }       
  }
}

``

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can update attributes for an element using setAttribute function

tr.setAttribute('data-exclude', true)

You can use getAttribute function to get the value of a specific attribute. Note that value is returned as a string and need to be converted to a boolean value in your case to filter

about 4 years ago · Juan Pablo Isaza Denunciar
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