Codebits and jQuery


Hi folks,

I have been playing with jquery in the codebits but it doesn't seem to work.

In my scripts.js file - A simple alert to test if is working but it doesn't work?


In the header file of my HTML

I cannot add the script tags here in the forum?! Anyway that is not the issues, my jQuery is not working!

Please help :smile:

$(document).ready(function() {

For me your Code works fine.

Please refresh the browser and maybe clear the cache.


Hey Benjamin,

There are two common problems people have getting started using jQuery on their own:

  1. Not linking to jQuery at all. It looks like you're doing that, just make sure it looks like this:

    <script src=""></script>
  2. Or, linking to jQuery after the link to their other script. You need to link to jQuery before, like so:

    <script src=""></script>
    <script src="script.js"></script>

Are you doing both of those properly?


Oh, and I forgot to mention: the reason your <script> tags are getting stripped out of the post is because Markdown (the formatting language this forum uses) automatically strips out all HTML tags as a security precaution. If you want to show a small part of code (like <script>), you just surround your code with a backtick (`) on either side. And for a block of code like above, you surround it with a new line and three backticks before and after. Example:

# blank line
``` # three backticks
# block code goes here
``` # three backticks
# blank line

# small bit of code: `<script>`

I hope this helps :)