Jquery tutorial for beginners with examples

Now i have started learning JQuery so i wanted to have my own concise tutorial article for JQuery. I hope this will be helpful to other beginners too.

Note*: There are other tutorial on web which is quite good, basically JQuery’s own tutorial. If you are looking for more details you can also look for the API document of JQuery.

What is JQuery and What is not

JQuery is open source lightweight Javascript Library which is used to simplify interaction between HTML and JavaScript. 

JQuery is not a language. JavaScript is a Language. JQuery is built over JavaScript.

What JQuery can do

  • DOM Manipulation
  • CSS Manipulation
  • AJAX
  • Effects and Animation

How to use JQuery

You can start using JQuery by adding JQuery library in HTML file.

 

Imp Point in above code

  • Here we are using JQuery.min.js instead of JQuery.js. In Production you should use minified version of library. It will load fast as it doesn’t contain unnecessary comment and whitespaces.
  • JQuery is getting loaded from Google CDN instead of self hosting. It will again make your site load faster. Also it will help you website take advantage of cache.

JQuery Syntax

Now we know how to use JQuery in web page. Next step would be using JQuery syntax. Common syntax for JQuery would be

$(<Where_to_do_Action>).<When_To_Do_Action>(<What_To_Do>);

Example of JQuery Syntax

I want to show an alert message when ever document is ready or loaded completely.

Where(Selectors) : On Document.

When (Action): Document is in ready state or loaded completely.

What(Function) : Show an alert message.

Syntax in JQuery for above requirement

Different options for Selector(Where)

All Element – *

Current HTML element – this

Class –   .<Class_Name>   (look for dot)

Id – #<Id_Name> (look for #)

HTML element 

  • a (hyperlink)
  • table
  • tr
  • td
  • p
  • …….

 

Complete HTML Code

9 Comments Jquery tutorial for beginners with examples

Leave A Comment

Your email address will not be published. Required fields are marked *