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

190
Views
¿Por qué no puedo usar una función de secuencia de comandos para afectar las variables en html escritas por un archivo JSON?

Con suerte, una pregunta rápida.

Estoy usando un archivo JSON para escribir algo de html y completarlo con variables del JSON y agregarlo a parte de mi archivo html. Esto funciona y está bien. Sin embargo, ahora quiero usar un script diferente para aplicar filtros de mostrar y ocultar basados en atributos de clase al html que se imprimió. Por alguna razón, esto no está funcionando. Si solo copio y pego el html con variables en el documento original después de haberlo impreso, entonces el script funciona. ¿Es esto un problema de sincronicidad?

Aquí está el segundo script que estoy buscando para ejecutar si ayuda:

 $(document).ready(function(){ var targets = $('.filter'), buttons = $('.filter-button'); buttons.click(function(){ var value = $(this).data('filter'); if(value == "all") { buttons.removeClass('checked'); targets.show(); } else { if($(this).hasClass('checked')) { $(this).removeClass('checked'); var checkedClasses = buttons.filter('.checked').toArray().map(function(btn){return $(btn).data('filter');}); if(checkedClasses.length == 0) { buttons.removeClass('checked'); targets.show(); } else { checkedClasses = $.grep(checkedClasses, function(n, i){ return n != value }), selector = '.' + checkedClasses.join('.'), show = targets.filter(selector); targets.not(show).hide(); show.show(); } } else { $(this).addClass('checked'); var checkedClasses = buttons.filter('.checked').toArray().map(function(btn){return $(btn).data('filter');}), selector = '.' + checkedClasses.join('.'), show = targets.filter(selector); targets.not(show).hide(); show.show(); } } }); });
about 4 years ago · Juan Pablo Isaza
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!