The h3 tag listener is not functioning as expected

I'm seeking assistance with the listeners for my pomodoro clock, specifically for minBreak and plusBreak. Oddly enough, the listeners for minWork and plusWork in jQuery are functioning properly, but the ones for minBreak and plusBreak are not. Any insights on why this might be happening? Below is the code snippet (please excuse the unfinished design)

$(document).ready(function() {
  //variables
  var workTime = 2; //working time
  var breakTime = 10; //break time
  var seconds = 00;
  var minutes = workTime; //setting clock = to workTime
  var clockDisplay = document.getElementById("display");
  var counterId = 0;
  var state = "on";

  //start clock whenc button clicked
  $("#start").click(function() {
    console.log("started!");
    setInterval(countDown, 1000);
    $(this).hide(); //hide start button
    $("#stop").show(); //show stop button
  });

  //stop clock when stop clicked
  $("#stop").click(function() {
    console.log("stopped!");
    state = "off";
    minutes = workTime;
    seconds = 0;
    clockDisplay.innerHTML = workTime + ":00";
    $(this).hide(); //hiding stop
    $("#start").show(); //showing start
  });

  //add work time
  $('.plusWork').click(function() {
    workTime++;
    $('.work').text(workTime);
    console.log(workTime);
  });

  //substract work time
  $('.minWork').click(function() {
    workTime--;
    $('.work').text(workTime);
    console.log(workTime);
  });

  //add break time
  $('.plusBreak').click(function() {
    breakTime++;
    $('.break').text(breakTime);
    console.log(breakTime);
  });

  //substract break time
  $('.minBreak').click(function() {
    breakTime--;
    $('.break').text(breakTime);
    console.log(breakTime);
  });

  //countdown function
  function countDown() {
    //if workTime = 0 reset counter and stop
    if (minutes == 0 || state == 'off') {
      clearTimeout(counterId);
      return;
    }
    //when seconds < 0 substract a minute
    else if (seconds < 0) {
      minutes--;
      seconds = 59;
      clockDisplay.innerHTML = minutes + ":" + seconds;
    } else {
      //if second single digit add 0
      if (seconds < 10) seconds = "0" + seconds;
      clockDisplay.innerHTML = minutes + ":" + seconds;
      seconds--;
    }
  }
});
body {
  background-color: #22313f;
  ;
}

.title {
  margin: auto;
  text-align: center;
  font-size: 30px;
}

.container {
  text-align: center;
}

h2 {
  font-size: 50px;
  margin: 0 0 0 0;
}

.clockContainer {
  position: relative;
  text-align: center;
}

#display {}


/* .timer {
      margin: 0 50px;
      margin-top: 70px;
      text-align: center;
      border: solid black 1px;
      font-size: 44px;
      width: 500px;
      height: 200px;
      display: inline-block;
      
    } */

.controlContainer {
  position: absolute;
  text-align: center;
  width: 100px;
  display: inline-block;
}

.control {
  width: 100px;
  height: 100px;
  border-radius: 100px;
  border: solid black 1px;
  text-align: center;
  margin-bottom: 20px;
}

.button {
  margin-top: 30px;
}

.hide {
  display: none;
}

.time {
  margin-top: 5px;
  margin-bottom: 5px;
  font-size: 20px;
}

.ticker {
  display: inline-block;
  font-size: 30px;
  margin-top: 0px;
}

.minus {
  margin-right: 10px;
}

.plus {
  margin-left: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
  <!-- header title -->
  <div class="title primary-text">
    <h1>Pomodoro Clock</h1>
  </div>
  <!-- clock container -->
  <div class="clockContainer">
    <h2>Session</h2>
    <!-- timer / clock -->
    <div class="timer">
      <h1 id="display">30:00</h1>
    </div>
    <!-- this section for controlling clock -->
    <div class="controlContainer">
      <div class="control">
        <div id="start" class="button title">Start</div>
        <div id="stop" class="button hide title">Stop</div>
      </div>
      <div class="control">
        <h3 class="time work">30</h3>
        <h3 class="title">Work</h3>
        <h3 class="minWork ticker minus">-</h3>
        <h3 class="plusWork ticker plus">+</h3>
      </div>
      <div class="control">
        <h3 class="time break">10</h3>
        <h3 class="title">Break</h3>
        <h3 class="minBrake ticker minus">-</h3>
        <h3 class="plusBrake ticker plus">+</h3>
      </div>
    </div>
  </div>
</div>

Answer №1

There is a minor mistake in the h3 class:

<h3 class="minBrake ticker minus">-</h3>
<h3 class="plusBrake ticker plus">+</h3>

The correct version should be:

<h3 class="minBreak ticker minus">-</h3>
<h3 class="plusBreak ticker plus">+</h3>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Preventing Repeated Clicks in AngularJS

Looking for a better approach to handle double clicks in AngularJS other than using ng-disabled. I have a solution to disable double/multi-click functionality on button click and re-enable it after completing an ajax process. Any suggestions? When our cod ...

Improper Placement of Bootstrap 5 Modal

I seem to be facing an unexpected issue where the Bootstrap 5 Modal and other components are displaying inside the sidebar menu instead of the main content area. Has anyone encountered this problem before? How can it be resolved? Here is a test example: ...

Grab Text Class - Python Selenium Automation

I am attempting to extract an element from a webpage using Selenium in Python <span class="_2-1_O"><span dir="auto" class="_1jlxc _3Whw5">Ana Smith</span></span> My goal is to extract the name Ana Smith using Python: contact_name ...

Guide to generating a downloadable link using React and Express

In my React app, I have a button which is essentially a div. The Button Component returns this structure with all other elements as props: <button className={"button "+styleButton} onClick={handleClick}> {source && <img src= ...

Building a responsive CardMedia component with React Material UI

I am currently working on creating a gallery using React Material UI (utilizing Card, ...). I am facing some challenges in making the gallery responsive, especially with varying cover sizes: https://i.stack.imgur.com/2n6vf.png Here is the code snippet I ...

Is it possible to retrieve JSON data from the server without having to reload the page?

My approach to minimize server requests involves sending a JSON file to the client and working with that data instead. However, a challenge I'm facing is preventing the page from refreshing when receiving the JSON file. I want the data to be received ...

How can I line up the bootstrap datepicker with a bootstrap column?

I currently have Bootstrap 3.3.7 and a bootstrap datepicker version 1.6.4 integrated into my project. However, I am facing an issue where the datepicker does not fill up the designated column within a div with the class col-md-6. Here is the HTML code sni ...

Display of Navigation Bar in Angular is Not Proper

Currently diving into the world of Angular, I've encountered an issue with a material menu that isn't displaying correctly. The expected outcome based on my code should resemble this image: https://i.stack.imgur.com/z70Aq.png This snippet showc ...

Changing Settings on the Fly with JQuery

I am facing an issue with a table that has values generated dynamically using PHP, such as id and name attributes (e.g. id="question_". My challenge is how to set an element attribute considering this dynamic nature. For instance, I need to update the tex ...

Implementing a vertical tabindex change in Material UI Dialogue table

My material UI dialogue contains a table: <Dialog open={open} onClose={handleClose} maxWidth={'xl'} aria-labelledby='scroll-dialog-title' aria-describedby='scroll-dialog-description' disa ...

Use various onChange functions for sliding toggle

I need assistance with a toggle app I'm developing that includes two slide toggles. Even though I have separate onChange() methods for each toggle, toggling one slide-toggle also changes the value of the other slide toggle. The toggle state is saved i ...

Utilizing PUG for Iterating Through Multiple Items in Express Framework using JSON Data

I'm currently working on a small application using Express and PUG, aiming to achieve the following: https://i.stack.imgur.com/ZDyTK.png index.pug ul#restaurants-list li img.restaurant-img(alt='Mission Chinese Food', sr ...

Averages of window sizes visible without scrolling

Most designers target browsers with a resolution of 1024x768, although widths of 960 - 980px are also acceptable. (Personally, I prefer 960 for the chrome, but that's just my preference.) My query is - what window height can we generally assume for u ...

The application suddenly displays a blank white screen after encapsulating my layout with a context provider

Here is the custom layout I created: export const metadata = { title: "Web App", description: "First Project in Next.js", }; export default function CustomLayout({ children }) { return ( <html lang="en"> ...

The getter function is called before the v-if directive in the child slot component

I have developed a Vue component that needs to perform certain logic and based on that logic, I want to render the content inside the slot. <logic-component> <div>{{ data }}</div> </logic-component> The data is retrieved using a ...

Footer not being pushed down by content in mobile view on page

Hello everyone, Can you assist me with a query, please? My form works perfectly fine in desktop view, but it gets cut off on mobile view and I'm unsure of the reason why. Here is my code: .upload-pic { position: absolute; max-width: au ...

Containers shared among Next.js pages within a folder

Is it possible to have a shared container for all pages within a specific folder in NextJS? One potential solution could involve the following code: // pages/folder/index.js export default function Container({ children }) { return <Container>{ch ...

How can I show a loading screen while making a synchronous AJAX call in Chrome?

Is there any method to show a loading screen in Chrome while using async:false in an AJAX call? The use of setTimeout poses several challenges when making multiple synchronous AJAX calls within the setTimeout function. Additionally, the loading indicator ...

Sorting alphanumeric strings in React Bootstrap Table Next on a dynamic table

I am facing an issue with sorting columns in a dynamic table with over 70 columns using React-Bootstrap-Table-Next. The problem arises when trying to sort the columns in alphanumerical order, as some columns contain numbers and others contain letters. The ...

When I attempted to POST a js::array in JSON, the response returned "undefined:undefined"

I have a javascript array on the frontend that I need to send to my Tomcat server. Currently, I am using the following code but encountering issues: console.log("preview list. postUsers()"); console.log(Ext.getCmp("preview-container").get ...