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

104
Views
My onclick function doesn't recognize my class
  <div id="hoursList" class="hours__list"></div>

I will put some html tag inside to this class "hours_list".

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

This function works with this action.

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

Everything is ok, until now. But The problem is this " $(".hour_cell").click(function ()". This function doesn't work. I tested with consol.log but I couldn't see this message. So how can I solve this problem? Please, help me, I want to le

// Onclick hour cell
$(document).ready(function () {
  $(".hour_cell").click(function () {
    var th = $(this).data().hours.slice(0, 2);
    console.log("H E R 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!