J.Zil
J.Zil

Reputation: 2449

Calling javascript functions on pageload not working

This is the code I am using at the bottom of my javascript (just to test) in order to get my functions working on page load:

// Call to load     
$(document).ready(function()
{
    test();
}​

At the top of my javascript file I have this:

function test() {
alert("hello")
};

Why isnt my test being called?

Upvotes: 0

Views: 449

Answers (2)

Chris Hayes
Chris Hayes

Reputation: 12020

Look closer at your jQuery call:

// Call to load     
$(document).ready(function()
{
    test();
}​

You're missing the end ) and a semicolon.

// Call to load     
$(document).ready(function()
{
    test();
}​);

You could tell this if you checked the console in your browser.

Upvotes: 6

user1796666
user1796666

Reputation:

There's a typo(you missed one bracket):

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

Upvotes: 4

Related Questions