Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Where to place Javascript?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28245
    realph
    Participant

    Hey guys I’m trying to follow this tutorial on the site: https://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

    #71878
    leonzinger
    Member

    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:


    #71883
    Rob MacKay
    Participant

    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 :)

    #71973
    realph
    Participant

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.