I have the following code.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script type="text/javascript" src="jquery-1.4.2.min.js" ></script> <script type="text/javascript"> function myFun() { alert(5) } $(document).ready(function(){ $("#myID").click(myFun()); }) </script> </head> <body> <input type="button" value="Click it" id="myID" /> </body> </html>
When I run this code, then alert(5)
comes when the page loads. If i write
$("#myID").click(myFun)
This warning appears only when the button is pressed. Why is he acting like that?
source share