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

138
Views
Intentando invocar el método onchange establecido por jQuery

En mi código, estoy configurando un detector de cambios en mis casillas de verificación aquí

 $(".section").change(function() { if($(this).is(":checked")) { $("." + this.id).show(); ...

Ahora estoy tratando de hacer un clic "controlado por código" en la casilla de verificación, y tengo

 $(".secTitle").click(function(e) { var elem = this; while(elem) { if (elem.className && elem.className.indexOf ('DOC_SECTION') != -1) { var clzes = elem.className.split(" "); var clzIdx = 1; if (elem.getAttribute('closeSecClassIdx')) { clzIdx = parseInt(elem.getAttribute('closeSecClassIdx')); } var chk = document.getElementById(clzes[clzIdx]); chk.checked = false; alert(chk.onchange); //chk.changed(); break; } else { elem = elem.parentNode; } } });

Sé que tengo el elemento correcto, como chk.checked = false; está funcionando correctamente. Después de eso, estoy tratando de invocar el método de cambio establecido anteriormente, pero mi alerta muestra "indefinido".

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede desencadenar el evento de change llamando a $(chk).change() . A continuación, he creado un pequeño prototipo que muestra el enlace al evento de change y lo invoca.

 jQuery(function($) { // bind to the change event $("input").change(function() { console.log('change triggered!'); }); // now trigger it $("input").change(); });
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="checkbox" />

over 4 years ago · Santiago Trujillo Report
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!