I got this multi step contact form and I want to add a class to a specific div depending on which step of the form I am.
The current step is specified with the class ".current". So as you can see, step 1 of my form is currently active (default on page load).
<ul class="multi-step-list">
<li class="step-1 current">Name</li>
<li class="step-2">Address</li>
<li class="step-3">Message</li>
<li class="step-4">Send</li>
</ul>
Now I have a div where I want to add a class, when step 2 is active with the class ".current" Depending on the step I am, ".current" switches automatically to my current step.
So when step 2 is active, I want to add the class ".myClass" to my div "myDiv".
jQuery(document).ready(function( $ ){
if($('li.step-2').hasClass('current')) {
$('div.myDiv').toggleClass('myClass');
}
});
I know I am wrong here because that would only take effect on page load and step 2 is pre-selected. ".myClass" should only appear when ".step-2" has class ".current" and when I switch to e.g. step 3, the class must disappear.
I hope I can get some advice here.