To ensure font-weight is applied to innerHTML text on Laravel, it must be styled with a white color for the changes to take

I have added a countdown feature to my Laravel 5 application and I am trying to adjust the font weight of the text, but I am facing some difficulties. When I set the color to #fff, the font-weight works perfectly fine, but when I change the color, the font-weight seems to stop working.

Here are some images for comparison: https://i.sstatic.net/x4TjB.png https://i.sstatic.net/OLQwP.png

The code in my blade.php file looks like this:

<a style="color: #fff" href="">
  <div id="countdown-component" style="display:inline;color:#EC1B33;font-weight:600;letter-spacing:2px;">
  </div>
</a>

Here is the JS function responsible for generating the countdown:

<script>
      // Set the date we're counting down to
      var countDownDate = new Date("Feb 15, 2022 12:00:00").getTime();
    
      // Update the count down every 1 second
      var x = setInterval(function() {
    
      // Get today's date and time
      var now = new Date().getTime();
    
      // Find the distance between now and the count down date
      var distance = countDownDate - now;
    
      // Time calculations for days, hours, minutes and seconds
      var days = Math.floor(distance / (1000 * 60 * 60 * 24));
      var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
      var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
      var seconds = Math.floor((distance % (1000 * 60)) / 1000);
    
      // Display the result in the element with id="demo"
      document.getElementById("countdown-component").innerHTML = days + " DAYS " + hours + " HOURS "
      + minutes + " MINUTES " + seconds + " SECONDS ";
    
      // If the count down is finished, write some text
      if (distance < 0) {
        clearInterval(x);
        document.getElementById("countdown-component").innerHTML = "EXPIRED";
      }
    }, 1000);
</script>

Any assistance on this matter would be greatly appreciated. Thank you.

Answer №1

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>    // Setting the target date for countdown
          var countDownDate = new Date("Feb 15, 2022 12:00:00").getTime();

          // Updating countdown every second
          var x = setInterval(function () {
            // Getting current date and time
            var now = new Date().getTime();

            // Calculating the distance between current time and target date
            var distance = countDownDate - now;

            // Calculating days, hours, minutes, and seconds
            var days = Math.floor(distance / (1000 * 60 * 60 * 24));
            var hours = Math.floor(
              (distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
            );
            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
            var seconds = Math.floor((distance % (1000 * 60)) / 1000);

            // Displaying the countdown in the specified element
            document.getElementById("countdown-component").innerHTML =
              days +
              " DAYS " +
              hours +
              " HOURS " +
              minutes +
              " MINUTES " +
              seconds +
              " SECONDS ";

            // If countdown is over, display expired message
            if (distance < 0) {
              clearInterval(x);
              document.getElementById("countdown-component").innerHTML = "EXPIRED";
            }
          }, 1000);
    <a style="color: #fff" href="">
          <div
            id="countdown-component"
            style="
              display: inline;
              color: #fff;
              font-weight: 400;
              letter-spacing: 2px;
            "
          ></div>
        </a>

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

What could be causing the redirection issue in a next.js application?

I recently started working with Next.js and have developed an application using it. On the homepage, I have a timer set for 10 seconds. When the timer hits 0, I want to redirect the user to a feedback page in my "pages" folder. Below is the code I am usin ...

Saving HTML code entered in a textarea field does not work with the database

Recently, I encountered an issue on my website related to storing news posts in HTML format. My initial approach was to write the posts in HTML for better presentation and then transfer this code into a Textarea element. The plan was to save this input in ...

Is it possible to extend the height of a floating child to match that of the parent element

Can CSS alone make this possible? The answer seems to elude me no matter where I look! I'm trying to create a left and right nav bar that extends to 100% height, essentially reaching the end of the page. There are three floated columns inside a float ...

What is the process for generating a fresh instance of an Angular service?

Hey there, I've been pondering a solution to a little dilemma I'm facing. Let me share my thoughts and see if you can lend some insight or tell me where I might be going astray. Setting the Stage: In the realm of angular app creation, it's ...

What is the process for configuring a registry for a namespaced package using yarn?

Experimenting with yarn as a substitute for npm has been quite interesting. With npm, we usually rely on both a private sinopia registry and the official repository for some namespaced packages, since sinopia doesn't support namespaces. My .npmrc fi ...

What could be the reason my code isn't successfully performing addition within the input field?

As a novice, I am practicing by attempting to retrieve a number from a text field, prompting the user to click a button that adds 2 to that number, and then displaying the result through HTML. However, I keep encountering an issue where NaN is returned whe ...

The useNavigate() function seems to be failing to redirect to the '/protected' route

The issue lies in the redirection process after receiving the token from the API. Although the token is successfully saved in local memory, the redirect to the intended page does not occur as expected. Instead, a manual window refresh is required to naviga ...

What is the best way to pass multiple arguments to a JavaScript function inside a string?

UPDATE the function name wasn't the issue (accidentally copied wrong one). The problem was that I was sending a string! Thanks to mplungjan, the problem is now fixed! This is the code snippet: $("#GVHistory").append("<tr><td>" + order. ...

The blend of Combination and Advanced Timeline triggers a "ReferenceError: Highcharts is not defined" error

Replication Steps First, download HIGHCHARTS 4.1.9 from http://www.highcharts.com/download Next, open the file index.html Then, click on Combinations > Advanced timeline An error message is displayed in Firebug and the chart does not appear: Referenc ...

Combine the arrays to utilize ng-repeat

I'm working with several arrays and I need to display them in a table using ng-repeat. Is there a way to combine arrays like name=[name1, name2] and type=[type1, type2] into a single array data=[..] so that I can use ng-repeat for data.name and data.t ...

Tips on positioning a dropdown item to the far right of the page

I need help moving the language switcher and its items to the right side of the page. I tried using ml-auto but it didn't work for me. Whenever I try to adjust the position with padding-left, all the items end up in the center of the page. Any suggest ...

What is the best way to store all rows in a dynamically changing table with AngularJS?

I am facing an issue while trying to dynamically add rows for a variable that is a String array in my database. The problem is that it only saves the last value entered in the row instead of saving all of them in an array. Here is my current view code: &l ...

Code for a regular expression that permits either letters or numbers with symbols

Here is the code snippet I am using for data validation in jQuery: return /^(?=.*[A-Za-z0-9/\$#.-_])[A-Za-z0-9/\$#.-_]$/i.test(value) The requirement is that the value should begin with letters or numbers, or a combination of both. Afterwards, ...

Is it possible that the HTTP module's deflate compression is only effective on specific CSS files and not all

I've been working on setting up mod deflate and gzip on my server, and while it's mostly functioning smoothly, I've noticed that not all files are being caught. It's not a matter of missing ALL javascript or CSS, but rather that some ar ...

What is the best way to position a single element in React using the Grid Component without causing any overlap?

I am struggling with positioning 3 components on my react page: PageHeader, SideMenu & FeatureList (which consists of Display Cards). Here is the code for each component: App.js // App.js code here... PageHeader.js // PageHeader.js code here... SideMenu ...

Top Bootstrap dropdown menu overlaid with Leaflet zoom buttons

I'm encountering an issue depicted in the screenshot below. Is this related to bootstrap or leaflet? How can I adjust the position/style of the dropdown menu so that it appears above all other elements? https://i.sstatic.net/cQhN5.png ...

Animating the height property in Angular 2 with precise timing during data binding

Seeking a way to have a component called information-board that animates away after a few seconds, I decided on making it slide up as an exit animation. My plan is to achieve this using CSS animations as discussed in this thread: Angular 2 Slide Up and Dow ...

The VueJs component refuses to display within the modal until I manually trigger a re-render by adjusting the window size

Currently, I have integrated "Carousel-3d" into my project globally by importing it like this: import Carousel3d from 'vue-carousel-3d' Vue.use(Carousel3d) You can find the source and more information about it here: After importing it, I attemp ...

Instructions on keeping a numerical counter at its current value for all site visitors

Recently, I integrated a number counter into my website. However, I am facing an issue where the count resets to zero whenever a new visitor accesses the site. I'd like the count to remain persistent and update based on the previous count. For instanc ...

Angular JS displays an error message when the user selects an input field and fails to provide any input

On my wizard steps application, I have implemented Angular JS validation that displays errors when the user enters and removes a character in the input field. However, I am trying to figure out how to show the error message if the user tabs onto the fiel ...