Grow your CSS skills. Land your dream job.

Auto start jQuery function

  • # March 24, 2011 at 12:28 pm

    I would like this pop-up to appear when the page loads. I don’t want for a button to be pushed or any action like that.
    Is there like an auto run action?

    http://goodwynbuilding.com/test/

    $("#button").click(function(){
    //centering with css
    centerPopup();
    //load popup
    loadPopup();
    });

    Thanks

    # March 24, 2011 at 3:23 pm

    This should work:

    $(document).ready(function() {
    //function to open the popup
    })
    # March 28, 2011 at 10:01 am

    I already have that.

    $(document).ready(function(){


    //LOADING POPUP
    //Click the button event!
    $("#button").click(function(){



    //centering with css
    centerPopup();
    //load popup
    loadPopup();
    });

    //CLOSING POPUP
    //Click the x event!
    $("#popupContactClose").click(function(){
    disablePopup();
    });
    //Click out event!
    $("#backgroundPopup").click(function(){
    disablePopup();
    });
    //Press Escape event!
    $(document).keypress(function(e){
    if(e.keyCode==27 && popupStatus==1){
    disablePopup();
    }
    });

    });
    # March 28, 2011 at 11:18 am

    Try taking out the first button click:

    $(document).ready(function(){

    //centering with css
    centerPopup();
    //load popup
    loadPopup();

    //CLOSING POPUP
    //Click the x event!
    $("#popupContactClose").click(function(){
    disablePopup();
    });
    //Click out event!
    $("#backgroundPopup").click(function(){
    disablePopup();
    });
    //Press Escape event!
    $(document).keypress(function(e){
    if(e.keyCode==27 && popupStatus==1){
    disablePopup();
    }
    });

    });
    # March 28, 2011 at 11:34 am

    Thanks that worked, but now I cant figure out why it has disabled these two…

    	$("#popupContactClose").click(function(){
    disablePopup();
    });
    //Click out event!
    $("#backgroundPopup").click(function(){
    disablePopup();
    });
    # March 28, 2011 at 11:37 am

    not sure. Are you using a plugin? It might assign id’s to objects on the first click, so now the id’s aren’t being assigned because there’s no initial “click” action. Really am guessing on this on though. :/

    # March 28, 2011 at 11:39 am

    Nevermind! I see I had to move the brackets out to include all.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".