0

Here is a link to some code that i would like to implement.

http://jsfiddle.net/g7gYy/12/

I am having a bit of trouble working out where to place the code and to actually get it too work.

Here is an html file that I have uploaded: http://www.canning.co.nz/Game/testmarquee.html

Can I please have some help with this?

thanks

3
  • 2
    You need to include jQuery in html file you provied. Commented Apr 6, 2012 at 12:00
  • Mateusz W: Can you please advise me on what to do to add jQuery? I have not used it before. Commented Apr 6, 2012 at 12:18
  • check my answer for that Commented Apr 6, 2012 at 12:52

2 Answers 2

1

First you didnt added jquery lib to your page add it.

<script src="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

Next put all your code in document ready because before document get ready your code get executed but elements are not ready to do some operations

$(document).ready(function() {
    var $text = $('.text-to-scroll', $marquee);
    var textWidth = $text.width();

    var $marquee = $('#marquee');
    var marqueeWidth = $marquee.width();
    $marquee.css('height', $text.height());

    function animateLoop()
    {
        //First lets put if out of view to the left
        $text.css('left', -textWidth);
        //Now it's out of view, change it's display from none to block
        $text.css('display', 'block');

        //Now we can animate it so that if scrolls across the screen
        //http://api.jquery.com/animate/
        $text.animate({ 'left' : marqueeWidth }, 10000, 'linear', animateLoop);
    }
});
Sign up to request clarification or add additional context in comments.

Comments

0

Your javascript file link is not good.

<script language="JavaScript" type="text/javascript" src="marquee.js">

make sure the marquee.js file is in the same folder as your testmarquee.html page.

Later Edit:

Ow, scratch that, i was wrong, Mateusz was in fact right.:D

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.