A
A
Abror Jakey2015-09-25 07:35:08
JavaScript
Abror Jakey, 2015-09-25 07:35:08

How to properly handle Click?

There are 5 blocks with the same class with nested divs, there is a click handler, how to make it so that when you click on a certain block, this particular block opens, and when you click on another block, the previous one closes and the one you clicked opens ...

<div class="mini-wrapper" data-mini-wrapper-id="">
        <div class="mini-main" data-mini-main-id="">
            <?php print render($items[0]);?>
        </div>
        <div class="mini-selector" data-mini-selector-top-id="">
            <?php foreach ($items as $delta => $item): ?>
                <div data-mini-selector-id="<?php echo $delta?>">
                    <?php print render($item)?>
                </div>
            <?php  endforeach?>
        </div>
    </div>

This block is repeated 5 times, when you click on the "mini-wrapper" opens the "mini-selector"

here is the js
$("div.mini-wrapper").click(function (e) {

    $(this).find("div.mini-selector").fadeToggle('fast');
    /* тут остальной код */

});


here is an example

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
littleguga, 2015-09-25
@ayyjay

Like this
Just store the previous object in a variable and collapse it before opening a new one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question