Get the App
SLTechnology News&Howtos  ›  Development  › 

Is there a difference between javascript and jquery?

Shulou Source: shulou.com Published: 2022-06-03 17:38:27 09月23日 Update

This article mainly explains "is there a difference between javascript and jquery"? the content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "is there a difference between javascript and jquery"?

The operating environment of this tutorial: windows7 system, javascript1.8.5&&jquery1.10.0 version, Dell G3 computer.

First, the essential difference

1.JavaScript is a lightweight programming language that can be executed by all modern browsers by inserting tags into HTML pages.

2.JQuery is a library of JavaScript functions. Or one of the most popular frameworks in JavaScript.

The first thing to use JQuery is to add a reference to the jQuery library at the beginning of the HTML code, such as:

Library files can be placed locally, or you can directly use the CDN of well-known companies, the advantage is that the CDN of these large companies is more popular, users are likely to be cached in the browser when visiting other websites before visiting your website, so it can speed up the opening of the website. Another benefit is obvious, saving the traffic bandwidth of the site. For example:

/ / Google or: / / jQuery official II. Grammatical differences

1. Different methods of manipulating element nodes

A.JavaScript usage

GetElement series, query series

Ha heh he / / is an array, even if there is only one element, you need to use [0] to get the first one and then use document.getElementsByName ("na"); / / is an array, even if there is only one element, you need to use [0] to get the first and then use document.getElementsByTagName ("li") / / is an array, even if there is only one element, you need to use [0] to get the first one and then use document.querySelector ("# div"); / / is an element document.querySelectorAll ("# div li") / / is an array, even if there is only one element You need to fetch the first one with [0] and then use _ JavaScript: using get (index) or [index] to select the JavaScript object * $("p"). Get (0). Onclick = function () {} * $("p"). [0] .onclick = function () {} * ② JavaScript-- > JQuery: wrap the JavaScript object with $() (we find that JQuery is an array no matter how many objects it gets You can add an event directly to the entire array) * var p = document.getElementById ("p") * $(p) .click (function () {}); thank you for reading. The above is the content of "is there a difference between javascript and jquery?" after the study of this article, I believe you have a deeper understanding of the difference between javascript and jquery. The specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Node object element attribute event function text method array different only style code parameter website selection content document page learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MySQL Docker macOS Redmi