0

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?

2
  • 1
    there's a typo but in the first func - you should close like test();}) Commented Nov 12, 2012 at 16:16
  • Just want to mention that in JS very often you would prefer to do your testing with console.log(). Commented Nov 12, 2012 at 16:25

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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

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

1 Comment

You'll throw an error with that function call. It has one too many )

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.