Ensure that the menu remains hovered even after navigating to the submenu

I have successfully created a menu using CSS and JavaScript that reveals images and text upon hovering over the menu sections. However, I am facing an issue where the colors of the menu items revert back after hovering out.

You can view the website here:

Below are the CSS and JS codes used:

.product-block-botton {
    border-right:#ffffff solid 1px;
    text-align:center;
    vertical-align:middle;
    font-size:16px;
    padding:5px;
    height:30px;
    color:#ffffff;
}
.product-block-botton:hover {
    color:#000000;
}
.last-button {
    border:none;
}
.type1 {
    background-color:#B83E6C;
    cursor:pointer;
    width:25%;
}

HTML

<table class="product-block">
<tr>
    <td colspan="4" class="product-block-head">CHOISISSEZ VOTRE SAC
    </td>
</tr>
<tr>
    <td class="product-block-botton type1">Sac Papier Luxe</td>
    <td class="product-block-botton type1">Sac Poignées Torsadées</td>
    <td class="product-block-botton type1">Sac Poignées Plates</td>
    <td class="product-block-botton last-button type1">Sac Réutilisable</td>
</tr>
</table>

JS

<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function(e) {
    $j('.product-block-botton').each(function(index, element) {
        $j(this).hover(function(){
            $j('.categories').hide();
            $j('.categories').eq(index).show();
        });
    });
});
</script>

I hope this explanation is clear and thank you in advance for your help.

Answer №1

To implement the hover effect using jQuery, you can use the following code:

$j(this).on('mouseenter', function(){
   $j(this).addClass("hovered");
});

Then, in your CSS file, style the hovered class like this:

.product-block-botton.hovered {
   color: #000000;
}

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

Checkbox malfunctioning when trying to add values after being checked

I have successfully completed a calculation system project using JavaScript. Everything works well, the calculations are accurate and taxes are included properly. However, I am facing an issue where the tax is not being included when I click on the checkbo ...

Ways to implement the tabIndex attribute in JSX

As per the guidelines provided in the react documentation, this code snippet is expected to function properly. <div tabIndex="0"></div> However, upon testing it myself, I encountered an issue where the input was not working as intended and ...

Adding identifiers to columns in DataTables depending on the value of another attribute

I am facing a challenge with inserting the <span> tag into the "salesStatusName" column cell that already contains some data. This should only happen when the value of the last column, "completelyDelivered", is true. However, I do not want to display ...

"Troubleshooting the issue of AngularJS $http patch request failing to send

The information is successfully logged in the console when passed to replyMessage, but for some reason, the API does not seem to be receiving the data. Is the input field perhaps empty? replyMessage: function(data) { console.log(data); ...

Utilizing on() in conjunction with a map function

Currently, I am in the process of refactoring my code and have decided to revisit how I handle on events by utilizing mapping. Below is a snippet of what I currently have: $('img#sorc').on({ mousemove: function (e) { alert('tes ...

Submit Button Field - HTML ButtonFor

Being relatively new to MVC Razor and web development, both front-end and back-end, I'm in need of a button that can send a stored value to the controller/model. I attempted to mimic the functionality of Html.TextBoxFor by giving it attributes similar ...

Why is my Bootstrap Carousel Switching Images but Refusing to Slide?

I've encountered a problem with my bootstrap carousel. The slide effect doesn't seem to be working, even though I have added the "slide" CSS tag. Instead of sliding, the images just quickly change without any transition. Here are some key points ...

Is it necessary to have NodeJs in order to host a React app on a server?

I've been working on a .NET Core 2.2 project with React integration, As I'm nearing completion of the project, I have a query that has been on my mind. Do I need Node.js installed on the server for React to function properly? Thank you. ...

What is the best way to duplicate and delete the final child element using jQuery?

Can someone help me troubleshoot this code that is supposed to clone and remove the last child of a ul element? It doesn't seem to be working as expected. $(document).ready(function () { var tmp1 = ''; var tmp = '<ul>< ...

Displaying the information fetched using axios on the screen using node.js

Is there a way to display the information from the input boxes in the image on the screen using node js? ...

Utilizing multi-layered arrays for enhancing bootstrap tables

My challenge involved handling a multidimensional array with varying elements in each subarray. I attempted to construct a Bootstrap table by parsing this array. Essentially, my goal was to create a 4-column table using mdArray[0], mdArray[1], mdArray[2], ...

Combine the elements to form a single text string with JavaScript

I initially used getElementById and it worked successfully. However, I now need to apply the same functionality to multiple div elements, so I switched to using classes. But now, when I use getElementsByClassName, it returns as undefined. (This function i ...

Modify the CSS selector for a dropdown menu element upon selection

I have customized a select box using CSS, but I am facing an issue where the custom arrow remains upward even after selecting an option. I want the arrow to point downwards once an option is chosen and revert to the default position when clicked outside. ...

Experiencing problems with integrating Slim framework and AngularJS, such as encountering a 404 error

Although this may seem like a repeat question, I am encountering an issue with using AngularJS with Slim Framework web services. I have set up a webservice to retrieve a student record with a URL structure like: http://www.slim.local/api/getstudent/1 ...

Issue: setAllcategories function not found

Currently engaged in using Next.js and Sanity as a Headless CMS for the backend. In the code snippet below, I have created a Categories.js file in the components folder to fetch some data. My objective is to extract all the titles from the category Array. ...

Executing a function with a parameter when clicking on a jqgrid cell

I'm attempting to change the color and make a cell clickable if it meets certain criteria. However, I am running into an issue with passing parameters to the onclick function of the element. Here is what I am trying to do: { name: 'numberOfU ...

Maintain the selected list item after filtering in AngularJS

I am facing an issue with highlighting selected items in a list. I have three first names: Roy, Sam, David displayed in a ul as list items. Initially, I can toggle each li on click just fine. However, after performing a search and returning to the list, th ...

Can you guide me on how to establish a cookie within a selenium webdriver javascript script?

I am trying to figure out how to set a cookie using a basic webdriver script: WDS.sampleResult.sampleStart(); //WDS.driver.manage().addCookie(new Cookie("connect.sid", "s%3AeexeZcd_-S23Uh30e3Dmd4X9PskWF08s6m5hDurDa5Jj66SupmmiqvKEjAg6HGigl0o0V%2B9R7m4", ...

Asynchronous AJAX using JSONP

I'm facing a dilemma: it seems impossible to disable the asynchronous mode in $.ajax while using jsonp (http://api.jquery.com/jQuery.ajax/, async section). This means that the code snippet below will return "null" on the first call and the actual data ...

Resolving the CORS predicament caused by the ionic/angular's HTTP interceptor

I am currently using Ionic for both web and mobile development. However, I have encountered a CORS issue when integrating it with an HTTPS URL. Interestingly, the issue seems to be resolved after removing the HTTP interceptor. Nevertheless, I am seeking a ...