Wolfpack'08
Wolfpack'08

Reputation: 4128

Very basic anonymous function failure in jQuery?

The code is:

$function readyFin(jQuery() {
  console.log('ready!');
}

$(document).ready(readyFin);

If you can think of a better title for this question, please advise.

I am expecting to see 'ready!' in the javascript console in Chrome, but I do not. Why?

Upvotes: 2

Views: 467

Answers (3)

Samich
Samich

Reputation: 30115

Use function instead of $function:

function readyFin() {
  console.log('ready!');
}

Example with anonymous function:

$(document).ready(function() {
    console.log('ready!');
});

Upvotes: 3

Gagandeep Singh
Gagandeep Singh

Reputation: 5879

The corrected example

function readyFin(){
  console.log('ready!');
};

$(document).ready(readyFin);

jsfiddle link

Upvotes: 3

user497849
user497849

Reputation:

try this:

<html>
<head>
  <script type="text/javascript">
    function readyFin() {
      console.log('ready!');
    };
    $(document).ready(function() {
       readyFin();
    });
  </script>
</head>
<body>
</body>
</html>

please see http://docs.jquery.com/Tutorials:Introducing_$(document).ready()

can you see where the issue is?

Upvotes: 2

Related Questions