Consider following HTML snippet:

    <input type="button" value="Button 1" />
    <input type="button" value="Button 2" />
    <input type="button" value="Button 3" />
and jQuery code snippet:

        $(document).ready(function() {
            $("[type='button']").each(function(i) {
                for (var j = 0; j < i; j++) {
                    $(this).click(function() {
                        alert(this.value);
                    }).slideToggle(300);
                }
            });
        });
What will happend after clicking on button3?
Explanation
We will have two buttons after the page loading - slideToggle() will hide button2. On click at button3 the allert box will show the value of button3 two times.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты