简体   繁体   中英

Including jquery breaks my simple web page

Inexplicably, web pages that were rendering and functioning correctly have stopped working. As far as I know, I am using the same browser (Chrome v. 23.0.1271.64) that I was using before, same JQuery, etc. I tried upgrading JQuery to the latest version and I still have this problem. When I click on "Read Later" I see the message "Uncaught ReferenceError: foo is not defined index.html:14 onclick"

When I comment out the Jquery include, it works.

I've tried in Firefox and I get the same results.

Here's my web page:

<html>
  <head>
    <title>Kanban2go API Test Page</title>
      <script src="lib/jquery-1.8.3.min.js"/>
      <script>
          function foo(event) {
              console.log("Foo!")
              return true;
          }
      </script>
  </head>
  <body>
    <form action="#">
      <input type="submit" value="Read Later" onclick="foo(event);"/>
    </form>
  </body>
</html>

EDIT:

Thanks for all the replies. I up-voted all the answers pertaining to my question, but I can only accept one.

<script src="lib/jquery-1.8.3.min.js"/>应该是<script src="lib/jquery-1.8.3.min.js"></script>

Script is not self closing tag

Change

<script src="lib/jquery-1.8.3.min.js"/>

To

<script src="lib/jquery-1.8.3.min.js"> </script>

Always use </script> . Never self-close a script tag:

<script src="lib/jquery-1.8.3.min.js"></script>
<script>
          function foo(event) {
              console.log("Foo!")
              return true;
          }
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM