jquery function inside .ready

Posted by phil on Stack Overflow See other posts from Stack Overflow or by phil
Published on 2010-06-05T18:42:55Z Indexed on 2010/06/05 18:52 UTC
Read the original article Hit count: 170

Filed under:

Could anyone tell me why 'function()' right after .ready is needed to make the script work?

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("p").hide();
  });
});
</script>
</head>

<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button type="button">Click me</button>
</body>
</html>

© Stack Overflow or respective owner

Related posts about jQuery