jQuery: Linking Our Files

Welcome to the jQuery tutorial. In this post we will be linking our HTML, CSS, and jQuery files and then giving a brief example of how jQuery works. Let’s get started.

3370527.jpg

Linking our files:

HTML:(make a file and write this code and then save it as “index.html” make sure the extension is html)

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>

Script(jQuery):(make a file and write this code and then save it as “script.js” make sure the extension is js)

$(document).ready(function(){

});

Don’t worry about the code I will explain everything. Now, we have our files ready and all what we have to do is to link them. To do that, we will add a script tag, just like how we did in JavaScript.

Script tag:(added it before the closing of the head tag in the HTML file)

<!--Script tag -->
<script type="text/javascript" src="script.js"></script>

That’s it! We linked our files! Now let me explain the code in the “script.js” file.

    • $() tells jQuery that we will be doing something.
    • Putting document between the parentheses tells us that we’re about to work on the HTML document itself.
    • .ready(); is a function, or basic action, in jQuery. It tells that as soon as the HTML document is ready it will run.
    • Whatever goes in .ready()‘s parentheses is the jQuery event that occurs as soon as the HTML document is ready.

See you in the next post.

NOTE: MAKE SURE TO DOWNLOAD JQUERY

— CODE DAILY

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s