Beginner Series: jQuery Tutorial
Every beginner must start with the infamous “hello world” tutorial so that’s exactly what we’re going to do here.
Writing the Code
Next, we’re going to write the code that will be used to print “hello world” on the screen through jQuery.
First, we’re going to write the plain HTML, which will look like the snippet below. Please note that you can modify the displayed message to say whatever you want, so long as you use the right HTML tags.
<html> <head> <title>HTML Hello World</title> Hello World in HTML. </body> </html>
After you have added that content inside the HTML file and saved the document, you should be able to open it in a browser and see the following message, “Hello World in HTML.”
Next, you will add the following snippet of code into your HTML document along with the close tags, in order to call upon the jQuery library:
This is meant to go in the body of your HTML content at the very top.
These are the close tags and they belong at the end of the main content, just before the closing body tag:
<div id="hello"> </div>
So, the final product should look just like this:
After you have saved your HTML file, you should be able to open it using your browser; you will see two lines of text, one for the HTML code and the other for the jQuery code.
Disclosure of Material Connection: Some of the links in the post above are “affiliate links.” This means if you click on the link and purchase the item, I will receive an affiliate commission. Regardless, I only recommend products or services I use personally and believe will add value to my readers.