Implement a scrolling animation in your webpage to seamlessly transition between sections using HTML, CSS, or JavaScript

How can I implement a functionality where clicking on a checkbox button scrolls to the next section containing checkboxes, and there is also a select all button that scrolls to the bottom when clicked? Below is the code snippet with my attempt:

.select {
  margin: 4px;
  background-color: #06213B;
  border-radius: 4px;
  border: 0px solid #fff;
  overflow: hidden;
  float: left;
}

.select label {
  float: left;
  line-height: 4.0em;
  width: 26.0em;
  height: 4.0em;
}

.select label span {
  text-align: center;
  padding: 0px 0;
  display: block;
}

.select label input {
  position: absolute;
  display: none;
  color: #fff !important;
}


/* selects all of the text within the input element and changes the color of the text */

.select label input+span {
  color: #fff;
  font-size: 19px;
  font-weight: 500;
  font-family: default;
}


/* This will declare how a selected input will look giving generic properties */

.select input:checked+span {
  color: #ffffff;
  text-shadow: 0 0 0px rgba(0, 0, 0, 0.8);
}
...
<!doctype html>
<html>

<head>
  <title>Test</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css" />
  <script>
    window.addEventListener('DOMContentLoaded', function() {
      const checks = document.querySelectorAll('.chk');
      const checkAll = document.getElementById('selectAll')
      document.addEventListener('click', function(e) {
        const tgt = e.target;
        if (tgt.matches('.chk')) {
          if (tgt.id === "selectAll") {
            tgt.closest('div').querySelector('i').classList[tgt.checked ? 'add' : 'remove']('fa-circle-check');
            checks.forEach(chk => {
              chk.checked = tgt.checked
              chk.closest('div').querySelector('i').classList[chk.checked ? 'add' : 'remove']('fa-circle-check');
            })
          } else {
            tgt.closest('div').querySelector('i').classList[tgt.checked ? 'add' : 'remove']('fa-circle-check');
            checkAll.checked = [...checks].slice(1).every(chk => chk.checked); // check all sub checkboxes are checked
            checkAll.closest('div').querySelector('i').classList[checkAll.checked ? 'add' : 'remove']('fa-circle-check');
          }
        }
      });
    });
  </script>
</head>

<body>
  <div class="select action">
    <label>
      <input type="checkbox" class="chk" id="selectAll" value="1"><span><i class="fa-solid fa-circle"></i> &nbsp;</span>
   </label>
  </div><br clear="all" />
  <h2>Some other place</h2><br clear="all" />
  <br clear="all" />
  ...
  <div class="mypoints">
    <label>
      <input type="checkbox" class="chk" value="1"><span><i class="fa-solid fa-circle"></i> &nbsp;</span>
   </label>
  </div>
</body>

If you could provide any guidance, it would be greatly appreciated.

Answer №1

If you are aware of the number of checkboxes on your webpage, it can be easily implemented using simple HTML. The approach I suggest involves "wrapping" each checkbox with a link (

<a href="#"></a>
) and assigning an ID to each checkbox label. Subsequently, the link href will correspond to the ID of the next label.

.select {
  // CSS code for .select class
}

// More CSS code for different classes like .branded, .lifepoints, .mypoints

<!doctype html>
<html>

<head>
// JavaScript code for handling checkbox actions

</head>

<body>
// HTML code for implementing checkboxes with corresponding labels and IDs

</body>

For achieving a smooth scrolling effect, I recommend checking out W3Schools' guide on smooth scroll. This will enhance the user experience by eliminating the abrupt jumping effect currently present on the page.

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

Configuring headless unit testing with requirejs

Seeking a JavaScript unit testing environment, I feel like I'm on a quest for the Holy Grail. The criteria are as follows: testing Requirejs AMD modules isolating each module by mocking out dependencies ability to test in-browser during development ...

The bootstrap switch button remains in a neutral grey color

Ordinary: Initially clicked: Click again: After the second click, it remains grey and only reverts on a different action like mouse click or selection. Is there a way to make it go back to its original state when unselected? ...

Initiate a model refresh via the view using AngularJS

When the view, such as the value in a text input, is modified by an external JavaScript, it does not update the model. Is there a way to initiate a model update to retrieve all binding values from the view? P.S: I am unable to manually set the model valu ...

Looking to verify the presence of either key within an object using JavaScript

My goal is to determine whether at least one of the two specified keys exists in a particular object. let keys = ['foo', 'bar']; The object we are analyzing: let obj = { "foo": "value" } let obj1 = { "key& ...

Discovering the Data Structures within the d3.js Illustrations by the Talented Mike Bostock

Wondering how to decipher the structure of JSONs in examples by Mike Bostock, like this one (after being transformed using d3): http://bl.ocks.org/mbostock/3886208 I aim to replicate it with my own fabricated array of JSON objects without relying on load ...

Discovering the class name on the preceding line of HTML using Selenium WebDriver

Below is the HTML code snippet that I am working with: <!-- language: lang-html --> <td class="Schedule-col details"> <td class="Schedule-col timeslots"> <div class="timeslots-container" style="opacity: 1; visibility: visible;"> & ...

Hapi/Node.js Reference Error for Request: Troubleshooting the Issue

I am facing an issue with my two API handlers: module.exports.loginWeb = function (request, reply, next) { if (request.auth.isAuthenticated) { return reply.redirect('/'); } if(request.method === 'get'){ rep ...

Stop React router from changing routes when the back button is pressed and also close any open pop

Within my React application, I've integrated a popup on a specific page. However, when the user opens the popup and then hits the browser's back button, they are directed to the previous page rather than simply closing the popup. I've tried ...

What is the best method to utilize a promise to delay the execution of a function until the data is received and stored

Currently, I am facing an issue with my API where the model variable is returning undefined before any data is populated in the return_array. I am unsure of how to implement promises or another method to ensure that the variable waits for data to be fille ...

bootstrap hstack containing a table with scroll functionality

Trying to implement a scrollable table within a container alongside other components has proven challenging. While the table functions perfectly on its own, integrating other components below it has presented issues. The use of hstack and d-flex came to mi ...

Ways to stop MongoDB from getting locked

I have a write query that fetches data from a source every minute. However, I also have an application that needs to access this database. I don't necessarily need the new data instantly. The write query is causing a database lock, resulting in the n ...

Managing post and session data during PHP form submission

I've encountered an issue with my code structure. What I aim to achieve is: To validate if post values exist, then execute the query and show the results. If post values are not present, check for a session value. If session is available, manipulate ...

What could be causing the Jquery slider to malfunction when hosted on a server, despite working flawlessly on a local machine?

Why is the JQuery slider not working when hosted on a server but works perfectly fine locally? I have uploaded all the necessary content to my website. Here is the link to my hosted website: navarangtravels.com/jq/jq Please help me identify the error. &l ...

The JW Player unexpectedly restarts when the CSS position is set to fixed in Firefox and Safari 5.0

I've created a script that dynamically changes the positioning of a div element from static to fixed when the scroll bar reaches it. You can see this in action on my website here: example, where a floating video in the right column stays fixed as you ...

Exploring the capabilities of SVG and audio integration in web browsers

I am curious if it's possible to incorporate audio into an SVG file in a web browser. I came across this thread here, but unfortunately, I can't leave a comment =/ I tried implementing the code from this website, but it doesn't seem to work ...

Is there a way to rotate a symbol around its center without the need to specify its position on two separate occasions

I am working on placing tile symbols on a grid and aiming to achieve the following: Utilize tile coordinates for symbol placement (e.g. 4,2 instead of 85,43) Define the vertices of symbols using pixel coordinates (not tile coordinates) Rotate symbols arou ...

What is the best way to display an object in ReactJS?

My Object is: https://i.sstatic.net/QsQ1X.png I need to extract data from the recette-... endpoint in base64 format const articleList = Object.keys(this.state.users).map(key => { Object( this.state.users[key].recettes).map(data => { / ...

Strategies for extracting information from external websites using JQ or JS

Is there a way to extract the full HTML content of another website using jQuery and Javascript, and then parse that content by analyzing each tag and attribute in the response? Any insights or solutions would be greatly appreciated. ...

Capturing page titles accurately for timeonsite tracker in a single-page Angular app is challenging when navigating to other pages

Implemented the timeonsite JS tracker in my Angular web application using HTML tags as shown below, <script type="text/javascript"> var Tos; (function(d, s, id, file) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementByI ...

React Switch not displaying various pages correctly

After creating a new component to switch between pages on my React app, I encountered an issue where the HomePage renders correctly when entering the site, but clicking on navlinks does not work. Additionally, when trying to access the url /contacto, ins ...