April 16, 2012

jquery autoscroll plugin not firing

Question by preahkumpii

I am sure my issue is a result of my inexperience in jquery and javascript. I am trying to use an autoscroll jquery plugin. I just stares at me when I click the link that is supposed to activate the scroll. Can someone help? Here is what I have:
I have called the relevant scripts in the head tag.
In at the end of my body tag I have this:

<script type="text/javascript">
$(document).ready(function() {
$("a.hello").click(function () {
    $("#text").autoscroll("toggle", { 
        start: { 
            step: 50, 
            scroll: true, 
            direction: "down", 
            pauseOnHover: true 
        }, 
        delay: 5000, 
        ffrw: { 
            speed: "fast", 
            step: 100 
        } 
    });
});
});
</script>

Then, I am trying to fire the script using an anchor, like this:

<a href="#" class="hello">start/stop</a>

The id of the div that I want to ‘pause on hover’ is “text”.
The source and instructions of this plugin is found here. Thanks.

EDIT:
The function that calls some html from other files based on form selects and puts it into the <div id="text"></div>.

function clickMe() {
    var book = document.getElementById("book").value;
    var chapter = document.getElementById("chapter").value;
    var myFile = "'files/" + book + chapter + ".html'";
    $('#text').load(myFile + '#source')
}

Answer by Starx

You forgot to wrap the code inside a

$(document).ready(function() {
..
});

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!