-4

How can we differentiate jquery and javascript.?
Where we can use jquery not javascript and vice-versa.?

Sumit Singh
  • 15,743
  • 6
  • 59
  • 89
Ranjit Singh
  • 3,715
  • 1
  • 21
  • 35

4 Answers4

5

jQuery is just a javascript library. So jQuery is javascript.

Adam Heath
  • 4,703
  • 2
  • 35
  • 50
  • This probably isn't the best place to explain what javascript is, MDN have a good article on it (and it's generally a good referance): https://developer.mozilla.org/en-US/docs/JavaScript/A_re-introduction_to_JavaScript – Adam Heath Aug 07 '12 at 08:54
  • @user1530742 Have you tried to find [details](http://en.wikipedia.org/wiki/JQuery) and you weren't able to do so? – pankar Aug 07 '12 at 08:54
  • 1
    There are many scenarios where jquery fit perfect.For using a table as a template then make a clone of it and then use it wherever u want which is not simply possible in the case of javascript. – Ranjit Singh Oct 03 '12 at 20:11
4

jQuery is a JavaScript library, thus it is JavaScript - just think of jQuery as a means of writing less code to perform certain JavaScript functions and actions.

Have you had a look at the jQuery file you download and add to your project or application? What you find inside is... lots of JavaScript!

Are you asking when would you use jQuery instead of JavaScript and vise-versa? If so you will find a lot of articles out there on the web or even here on stackoverflow:

When to use Vanilla JavaScript vs. jQuery?

Javascript or jquery?

jQuery vs. javascript?

Community
  • 1
  • 1
Mike Sav
  • 14,805
  • 31
  • 98
  • 143
  • no problem, welcome to stackoverflow! If you find an answer helpful add a plus one by marking it up or choosing it as your answer! – Mike Sav Aug 07 '12 at 08:57
2

Javascript is a programming language which is THE dominant language on the web - every browser supports it natively.

jQUery is a library written in Javascript. So basically Jquery IS Javascript but Javascript is NOT jQuery.

Jquery is meant to make programming tasks easier which would otherwise need quite some effort when writing it with native javascipt. Also it is an additional layer which evens out some inconsistencies and differences between the several browsers (especially Internet Explorer...)

While javascript is natively available in every browser, you have to include the jQuery-script in order to use it's functions.

<head>                
   <script type="text/javascript" src="/path/to/jquery.js"></script> 
</head>

One example to illustrate the usefulness of jQuery is making an AJAX Call. Creating the AJAX-Request Object in Javascript would look like this:

if (window.XMLHttpRequest) {
    request = new XMLHttpRequest(); // Mozilla, Safari, Opera
} else if (window.ActiveXObject) {
    try {
        request = new ActiveXObject('Msxml2.XMLHTTP'); // IE 5
    } catch (e) {
        try {
            request = new ActiveXObject('Microsoft.XMLHTTP'); // IE 6
        } catch (e) {}
    }

The jQuery-Code would look something like this:

$.ajax(/*...some options here...*/);

Jquery is providing some easy functions to keep the annoying work away from the programmer.

Christoph
  • 50,121
  • 21
  • 99
  • 128
0

Well for starters you nee to include the JQuery file in your web page for you to be able to use it. Other than that, see the other comments (JQuery is a wrapper for javascript)

It's meant to ease certain aspects of coding javascript Sample taken from the JQuery site

 <html>                                                                  
 <head>                                                                  
 <script type="text/javascript" src="jquery.js"></script>          
 <script type="text/javascript">                                         
   // we will add our javascript code here                                     
 </script>                                                               
 </head>                                                                 
 <body>                                                                  
   <!-- we will add our HTML content here -->                                        
 </body>                                                                 
 </html>
Rohan Büchner
  • 5,333
  • 4
  • 62
  • 106