Choosing each item from a lineup, one by one

Currently, I am in the process of developing a small website with multiple pages. The main requirement for this project is to have a vertical menu on the home page. Implementing the menu was relatively easy.

I successfully added a hover effect to the vertical menu, and you can see how it looks by visiting this link: https://jsfiddle.net/Kelowna/nfa2h65r/

Here is the markup:

    <ul class="list-wave">
        <li class="wave-item"><a class="#" href="#">link1</a></li>
        <li class="wave-item"><a class="#" href="#">link2</a></li>
        <li class="wave-item"><a class="#" href="#">link3</a></li>
        <li class="wave-item"><a class="#" href="#">link4</a></li>
        <li class="wave-item"><a class="#" href="#">link5</a></li>
        <li class="wave-item"><a class="#" href="#">link6</a></li>
      </ul>

The script responsible for the hover effect is shown below:

    $( document ).ready(function() {
$('.list-wave').find('li > a').each(function(){
    $(this).hover( function(){
        $(this).stop().animate({'opacity': '1'}, 300)
        $(this).parents('.wave-item').prevAll().eq(1).children().stop().animate({'opacity': '0.4'}, 300)
        $(this).parents('.wave-item').nextAll().eq(1).children().stop().animate({'opacity': '0.4'}, 300)
        $(this).parents('.wave-item').prev().children().stop().animate({'opacity': '0.6'}, 300)
        $(this).parents('.wave-item').next().children().stop().animate({'opacity': '0.6'}, 300)

}, function() {
     $(this).stop().animate({'opacity': '0.3'}, 300)
     $(this).parents('.wave-item').prevAll().eq(1).children().stop().animate({'opacity': '0.3'}, 300)
     $(this).parents('.wave-item').nextAll().eq(1).children().stop().animate({'opacity': '0.3'}, 300)
     $(this).parents('.wave-item').prev().children().stop().animate({'opacity': '0.3'}, 300)
     $(this).parents('.wave-item').next().children().stop().animate({'opacity': '0.3'}, 300)
})
})

In my current stage of development, I am now looking to automate this same effect to run continuously in a loop but stop when the user hovers over the menu. As a novice in JQuery, I am facing some challenges achieving this. Although I managed to apply a class, targeting and implementing the effect across multiple elements has proven difficult for me.

If anyone could provide me with guidance on how to accomplish this task, it would be greatly appreciated!

Answer №1

Unfortunately, I am short on time to dedicate towards solving this issue at the moment. However, I can offer some helpful hints:

setInterval allows you to execute a function at specified intervals.

mouseenter / mouseleave triggers functions when the mouse enters or leaves a designated area.

<ul class="list-wave">
    <li class="wave-item"><a class="asdf" href="#">link1</a></li>
</ul>

Avoid using '#' to name classes.

This example demonstrates how it can work to some extent

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

Identify and automatically switch to the mobile site following a selection

Seeking a way to incorporate a redirect on my Joomla site that leads users to a mobile-friendly HTML5 app. After much thought, I've put together the following script: <script type="text/javascript> <!-- if (screen.width <= 800) { ...

Ways to detect when the window printing process has been completed

Within my application, I attempted to generate a voucher page for the user using the following code: var htm ="<div>Voucher Details</div>"; $('#divprint').html(htm); window.setTimeout('window.print()',2000); The &apo ...

Steps for accessing specific menu div on a new tab

I'm facing an issue with my one page website. Whenever I click on a menu item, it directs me to a specific div tag on the page. However, if I right-click on a menu item and select 'open in new tab', it opens the URL "www.mysite.com/#" instea ...

image in the background following the header

Live Example: http://jsbin.com/opokev/54 I am currently trying to set this image as the background image while also including a header, but as you can see in the demo, the header is overlapping the image. Is there a way I can rearrange this so that the h ...

Is it true that using <meta charset="utf-8"> specifies the character encoding of the document

According to what I've learned, an HTML document must include the <meta charset="utf-8"> element within the head section in order to be considered standard-compliant. What is the logic behind indicating the encoding of a file within the file it ...

Converting a JSON list into a JavaScript object for the purpose of creating a dynamic

Understanding how JSON's lists work when parsed as JavaScript objects is challenging for me. I am not very familiar with JavaScript, so there may be mistakes in my question and the proposed solution. Currently, I have a JSON file that needs to be conv ...

Content from PHP's unlink() function continues to persistently display

I run an Angular front end along with a PHP back end for my website. I utilize PHP's unlink function to remove specific images from Angular's assets folder: $fileToDelete = "../src/assets/images/".$name; unlink($fileToDelete) or die("Error delet ...

Adjusting the page width to ensure compatibility with all devices

I am facing difficulties with CSS regarding the properties width and margin. I am developing a webpage that should display properly on all devices, including PCs, smartphones, and tablets. I am using HTML <meta name="viewport" content="width=device-widt ...

To prevent the loss of form data, consider utilizing the input type button instead of the button element

I'm a bit hesitant to repost my question, but it appears that my initial query (Why won't my jquery display correctly) may have slipped through the cracks. My apologies for the lengthy block of code, but I'll include it all in hopes of provi ...

How Jquery's Ajax can terminate SQL processes in PHP

Currently, I have a script that reads a .CSV file line by line and inserts the data into a database using an "INSERT QUERY". I am looking for a way to allow the user to stop this script at any given time. Below is my AJAX call: postselect = $.post(&apos ...

The presence of a display block property within a div contained inside an li element results in extra whitespace

I am presenting the code below: <div class="settingsMenu" style="top: 135px; left: 149px; display: block;"> <ul> <li class="download" onclick="downTemplate('template1')">Download</li> <l ...

What is the best way to include a JavaScript variable within CSS styling?

I am currently implementing a dropdown menu system where the image of a parent div changes on mouse hover over a link, and reverts back when the mouse moves away. I have this functionality set up using a variable in my HTML code. Is there a way for me to m ...

Encountered a 404 error while handling the Express 4 module, indicating that the 'html' module could not be

I need to update my express app to handle 404 (and 500) errors by displaying HTML instead of plain text. I have been able to show text to the client for 404 errors, but now I want to show HTML instead. My 404.html file is located in the /app directory. Cu ...

Ajax function implemented successfully with stylish design

Hi there! :) I'm encountering an issue with my code. I am trying to create a dropdown filter using ajax, php, and json. The first dropdown menu (for selecting the build year of a car) is populated through php. The second dropdown menu allows users to ...

How can I make my modal box appear after someone clicks on selecting a college?

Can someone help me figure out how to display my modal box after clicking into the selecting list? I've already coded it, but I'm struggling with getting it to show up after the click event. Any assistance is appreciated! In the image provided, ...

The variability of jQuery values

I have created a website control with jQuery that features a long bar consisting of four colored divs. Users have the ability to drag the join between two divs in order to resize it, all within the confines of the bar itself (keeping the overall width of t ...

I am encountering an issue with the jquery.min.js file not loading when I try to utilize the Google CDN for jQuery

Currently in the process of learning about jQuery and testing its functionality, however, I am facing an issue where changes are not being reflected. The error message states that it is unable to load. I have confirmed that I am using Google CDN and also h ...

Error encountered when trying to show a modal using a PHP script

I'm encountering an issue with the modal system on my website. Let me share some code snippets: MODALS ARE BUILT WITH W3.CSS LIBRARY modal.js (including debug statements) let modal = null; let title = null; let content = null; $(document).ready(() = ...

The function driver.find_element is unable to locate an element using the "class_name" attribute

My attempt at using driver.find_element, with the "class_name" method to locate and click on a button for expanding rooms on this website resulted in an error message: raise exception_class(message, screen, stacktrace) selenium.common.exceptions.N ...

The :root selector has encountered a malfunction within the Angular component

I'm interested in experimenting with CSS variables in my Angular 11 component. <div class="main-content"> <a>Test Link</a> </div> Here is my app.component.css: div.main-content{ --main-color: red } a{ color: v ...