How to insert jQuery into my own html?

Lately I’ve been trying to insert jQuery into my own private html, but it doesn’t seem to explain it here, so I found some other code that said to put this

<\script src=“”>
I put the back-slash before the script cause it wouldn’t show unless I did.

But it doesn’t seem to make anything work better.

Ok, so it sounds like you are really at the beginning of getting into Javascript, which means that jumping right into jQuery is maybe not the best track to be on.

Start here to get an idea of what Javascript is and how to use it in a page:
MDN Primer on Javascript Basics

Start here to begin learning about including the jQuery javascript library on your page and how to begin using it:
jQuery introduction by jQuery Foundation

I do not recommend getting into using jQuery before you have a good conceptual understanding of the basics of Javascript. jQuery is a javascript library - written in javascript. To understand it and use it well (it’s very easy to use it poorly), it’s a very good idea to have a basic grounding in the fundamentals of javascript itself.

Hope that helps!

I’ve done a lot of JavaScript, I’m only just barely learning how to use jQuery. I just want to know how to insert the jQuery library.


should be <script src=“”></script> at least that is what I use

It’s the same as any other external javascript file - you should put a <script>

tag at the bottom of the body. with the src set to the location of the jquery library you want to use.

From there, you will insert your own script block below that one where you will put your custom code. You usually want to wait until the document ready event has been fired to execute your code to make sure that the document is fully loaded and ready to go.

Something like:

   $( document ).ready( function(){





So if I inserted this

<script src=""> $(document).ready(function() { $("#example").css("background","red"); }); </script>

Then it would change #example’s background-color to red, right?

Wrong, those are 2 different scripts, jQuery and your own and they should be declared separately (2 times). It will be something like
<script src=“”></script>

$(document).ready(function() {

hope I was clear enough :wink:
EDIT: dumb lt; char

Oook, thanks that was very helpful.