Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   Помогите сделать выполнение jquery при загрузке страницы (https://javascript.ru/forum/jquery/54736-pomogite-sdelat-vypolnenie-jquery-pri-zagruzke-stranicy.html)

acidjazzz 30.03.2015 12:53

Помогите сделать выполнение jquery при загрузке страницы
 
Друзья. Я в js пока не очень. Нашел всплывающее коно http://designhuntr.com/create-simple...y-modal-popup/

<h1>Light Weight Popup Modal Box With jQuery | Demo</h1>
<button id="popup_window" data-popup-target="#example-popup">Open The Light Weight Popup Modal</button>

<div id="example-popup" class="popup">
    <div class="popup-body">	<span class="popup-exit"></span>

        <div class="popup-content">
            	<h2 class="popup-title">Simple lightweight popup [Hit Esc to Stop]</h2>

            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ullamcorper nulla et gravida interdum. Quisque dignissim a turpis at posuere. Praesent cursus turpis magna, quis pulvinar est vehicula</p>
        </div>
    </div>
</div>


При нажатии на кнопку всплывает окно. А как мне сделать что бы это окно всплывало при загрузке страницы?

$(window).load(function(){
jQuery(document).ready(function ($) {

    $('[data-popup-target]').click(function () {
        $('html').addClass('overlay');
        var activePopup = $(this).attr('data-popup-target');
        $(activePopup).addClass('visible');

    });

    $(document).keyup(function (e) {
        if (e.keyCode == 27 && $('html').hasClass('overlay')) {
            clearPopup();
        }
    });

    $('.popup-exit').click(function () {
        clearPopup();

    });

    $('.popup-overlay').click(function () {
        clearPopup();
    });

    function clearPopup() {
        $('.popup.visible').addClass('transitioning').removeClass('visible');
        $('html').removeClass('overlay');

        setTimeout(function () {
            $('.popup').removeClass('transitioning');
        }, 200);
    }

});
});

рони 30.03.2015 13:03

acidjazzz,
убрать строки 4 и 9
либо в строке 9 дописать }).click();

рони 30.03.2015 13:05

acidjazzz,
и так на всякий можно выкинуть строки 2 и 35

acidjazzz 30.03.2015 14:27

Спасибо большое. Сработало

либо в строке 9 дописать }).click();


Часовой пояс GMT +3, время: 00:36.