Over time it has been developed into a full-featured programming language, which can even be run outside the web browser (more detail on this in our Node.js article).
What is jQuery?
Specifically, jQuery’s primary purpose is to make it easier to interact with the HTML DOM.
It also contains useful tools for retrieving data from APIs and web services using REST and AJAX.
What is the HTML DOM, and how is jQuery helpful with it?
When working with HTML webpages, the DOM (Document Object Model) is the tree structure formed by the HTML tags in it.
Each HTML element is represented in the DOM – paragraphs, tables, images, links – everything.
For example, consider this HTML table (called “peopleTable“) containing Name and Age columns:
<table id="peopleTable"> <tr> <th> Name </th> <th> Age </th> </tr> <tr> <td> Bob </td> <td> 34 </td> </tr> </table>
The DOM can be easily traversed using jQuery to select the table and add a row:
Above, jQuery finds the peopleTable and then finds the last row in the table and adds a new row after it (containing a record for Tim).
var newRow = document.getElementById('myTable').getElementsByTagName('tbody').insertRow(document.getElementById('myTable').rows.length); newRow.innerHTML = '<tr><td>Tim</td><td>21</td></tr>';
So, Which Should I Use?
What jQuery is not suitable for is server-side work. Applications running in Node.JS do not have an HTML page to traverse, so the purpose of jQuery isn’t relevant inside Node.js applications.