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

102
Views
Mi función onclick no reconoce mi clase
 <div id="hoursList" class="hours__list"></div>

Pondré una etiqueta html dentro de esta clase "lista_horas".

 function booking_hours(hourArray) { console.log("heyyyy"); var table; for (var i = 0; i < hourArray.length; i++) { // if (parseInt(hourArray[i].childNodes[0].nodeValue) < 9) table += "<div data-hours='0" + hourArray[i].childNodes[0].nodeValue + ".00-0" + (parseInt(hourArray[i].childNodes[0].nodeValue) + 1) + ".00' class='hour_cell'>" + "<p>" + "0" + hourArray[i].childNodes[0].nodeValue + ".00 - 0" + (parseInt(hourArray[i].childNodes[0].nodeValue) + 1) + ".00" + "</p></div>"; } document.getElementById("hoursList").innerHTML = table.slice(9); }

Esta función trabaja con esta acción.

 function xhttp() { // Create an XMLHttpRequest object const xhttp = new XMLHttpRequest(); var hourArray; // Define a callback function xhttp.onload = function () { var parser, xmlDoc; var text = this.responseText; parser = new DOMParser(); xmlDoc = parser.parseFromString(text, "text/xml"); hourArray = xmlDoc.getElementsByTagName("item"); booking_hours(hourArray); }; // Send a request xhttp.open("GET", "hours.xml"); xhttp.send(); }

Todo está bien, hasta ahora. Pero el problema es este " $(".hour_cell").click(function ()". Esta función no funciona. Probé con consol.log pero no pude ver este mensaje. Entonces, ¿cómo puedo resolver este problema? ?Por favor, ayúdenme, quiero dejar

 // Onclick hour cell $(document).ready(function () { $(".hour_cell").click(function () { var th = $(this).data().hours.slice(0, 2); console.log("HER E"); for (var i = 0; i < counterReservedHours; i++) { if (i + 1 == counterReservedHours && reservedHours[i] != th) { counterReservedHours++; reservedHours[i] = th; break; } else if (reservedHours[i] == th) { reservedHours.splice(reservedHours.indexOf(th), 1); counterReservedHours--; break; } } $(this).toggleClass("isSelected"); }); });
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!