Click here to Skip to main content
15,886,632 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, I managed to make the div autoplay and show their respective hidden text. But now, how can I made the current play div to be in brown background just like when I manually hover to that div.

Here is the codepen for you guys to see it.

An Anonymous Pen on CodePen[^]

What I have tried:

- Tried to post it on several other forums such as stackoverflow and sitepoint but no answer
- Tried to target the div and add background css to it but I've no idea where to put the code. Kind of new to jquery.
Posted
Updated 6-Aug-18 5:14am

1 solution

Add an "active" class selector with the appropriate styles:
CSS
.product-link:hover,
.product-link.active {
    background: #E6DCD0;
}

Add the "active" class to the first link:
HTML
<div id="link0" class="product-link active">

Add / remove the "active" class in the boxActivate function:
JavaScript
var boxActivate = function(id){
    $links.removeClass("active");
    $boxes.hide().filter('#box' + id).show().closest(".product-link").addClass("active");
}

You'll also want to set the initial display state for the second and third boxes to "none".

Updated demo[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900