Grow your CSS skills. Land your dream job.

Where to place Javascript?

  • # March 2, 2010 at 6:58 pm

    Hey guys I’m trying to follow this tutorial on the site: http://css-tricks.com/better-pull-quotes/

    I’ve got jQuery working on my page I just wanted to know whereabouts I enter this chunk of code (below).

    Code:
    $(document).ready(function() {
    $(‘span.pullquote).each(function(index) {
    var $parentParagraph = $(this).parent(‘p’);
    $parentParagraph.css(‘position’, ‘relative’);
    $(this).clone()
    .addClass(‘pulledquote)
    .prependTo($parentParagraph);
    });

    I’m not to familiar with Javascript. Thanks in advance.

    Raph

    # March 3, 2010 at 2:23 am

    Hey Realphy,

    Don’t count on me for sure, because i’m not sure where exactly this code should go.

    But i believe that you should enter this code in the <head> tag and of course add the <script> tag to wrap this code up.

    It should be like thit

    Code:


    Rob
    # March 3, 2010 at 5:07 am

    I would always put it in the head myself – although some people like to add it to the end of the document, others just before the item that is using the script. You can add it anywhere you want. :)

    EDIT: As long as you put it between the <script> tag :)

    # March 3, 2010 at 8:34 am

    I put my Javascript as the last thing before the </body> tag. Something like this.

    Code:

    # March 3, 2010 at 6:29 pm

    Thanks guys. I put it just before closing the body tag.

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

You must be logged in to reply to this topic.

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