A
A
Alex Sokol2015-10-06 11:44:47
JavaScript
Alex Sokol, 2015-10-06 11:44:47

Elementary switching of the active class. Simultaneously in several blocks?

<div id="a">
        <div class="active">a</div>
        <div>b</div>
        <div>c</div>
    </div>

    <div id="b">
        <div class="active">a</div>
        <div>b</div>
        <div>c</div>
    </div>

    <div id="c">
        <div class="active">a</div>
        <div>b</div>
        <div>c</div>
    </div>


I understand, but it doesn't work. Experience is not enough.

1. By clicking on a,b,c (in id="a") the active class should be switched. But it also needs to switch the active class simultaneously in the id="b" and id="c" blocks in the same order a,b,c.

In this case, id="a" is associated with id="b", and id="b" with id="c".

It's not difficult, right?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
littleguga, 2015-10-06
@littleguga

Like this?

M
Marcuzy, 2015-10-06
@Marcuzy

$('#a, #b, #c').click(function(){ $('#a, #b, #c').addClass('active'); });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question