Grow your CSS skills. Land your dream job.

How to add document ready to a javascript code?

  • # February 3, 2013 at 2:33 pm

    Hello!

    I have this javascript code which I achieved by helping of professionals on css-tricks:

    http://codepen.io/JoshBlackwood/pen/cqDib

    It’s working very well but I should put it’s script after my html codes and I want to put it’s code inside head tags and when I call it, it works.

    I think I should use (document) .ready but I don’t know how.

    Please help!

    thank you in advance!

    Alireza.M

    # February 3, 2013 at 2:38 pm

    If you’re using standard js you can use body onload but I’d recommend putting it at the bottom of the page so it doesn’t slow page load.

    Hope this helps!

    Cheers,
    Jeff

    # February 3, 2013 at 2:52 pm

    Thank you!

    But my pages flow is putting js scripts inside head and call them with a custom js file.

    I really apperciate you If you could help me to doing what I want.

    # February 3, 2013 at 10:28 pm

    just go…

    # February 4, 2013 at 3:25 am

    Use JQuery javscript libary and then you can use

    $(document).ready(function() {
    //your code here
    });

    and much more cool functions.

    # February 4, 2013 at 3:27 am

    That’s it.

    Now, it’s working as I wanted.

    Thanks amyth91 and Htmlmainiac !!!

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

You must be logged in to reply to this topic.

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