0

I need a jquery to function to run on page load. I could not get it to work so I took the page and jquery script down to bare bones yet it still does not work. Here is the page:

<head>
    <title>Jump Page</title>
    <link href="Styles/Site.css" rel="Stylesheet" type="text/css" />

</head>
<body>
  <script type="text/javascript" src="Scripts/jquery-1.5.1.min.js" />
    <script type="text/javascript">


          $(function () {
              alert("test");

          });

    </script>
        <div>Report data is being loaded...</div>
        <img id="spinner" src="Styles/spinner.gif" />
</body>


</html>

No alert is shown. I've been able to accomplish this in MVC - why is this extremely simple page giving me so much grief?

Note: No script errors are given in IE and the source looks identical to what is shown here.

1
  • That should work, did you forget to copy the jQuery file to the scripts directory? Commented Jun 9, 2011 at 22:13

3 Answers 3

4

The script tag cannot be an empty tag. Change to this and it should work.

<script type="text/javascript" src="Scripts/jquery-1.5.1.min.js"></script>
<script type="text/javascript">


      $(function () {
          alert("test");

      });

</script>
Sign up to request clarification or add additional context in comments.

Comments

3

You can't shorthand <script> tags, you need to put in the closing </script> tag

Comments

2

Close the script tag :

<script type="text/javascript" src="Scripts/jquery-1.5.1.min.js" /></script>

Comments

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.