JavaScript:它是一种主要的脚本编程语言,用于使网站更具响应性和交互性。它是与 HTML 和 CSS 一起用于创建网页的枢轴部分之一。如果 HTML 和 CSS 如此装饰和设计网页,则 Javascript 使网页动态化(我们可以说它赋予了它们生命)。 JavaScript 是一种主要的客户端语言。它不仅限于网站开发,还用于许多桌面和服务器程序(Node.js 是最著名的例子),一些数据库,如 MongoDB 和 CouchDB,也使用 JavaScript。每当您的浏览器解析一个网页时,它的责任就是在内存中创建一个树状结构的表示。
例子:
javascript
A loop with a continue statement.
loop will skip the iteration where k = 7.
javascript
On clicking the "Hide_me" button, I will disappear.
输出:
A loop with a continue statement.
the loop will skip the iteration at k = 7.
The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
The number is 6
The number is 8
The number is 9
JQuery: JQuery 是从 JavaScript 发展而来的 JavaScript 框架。它是最流行的 JavaScript 库,由 John Resign 发明,并于 2006 年 1 月在 BarCamp NYC 发布。它是免费的,是一个开源库,是一个快速、简洁、功能丰富的 JavaScript 库,还具有跨浏览器兼容性。 jQuery 的目的是让大众的生活更轻松,让他们可以轻松地使用 javaScript 开发网站和基于浏览器的应用程序。简而言之,我们可以说“JQuery 是一个提供更好的客户端网页开发的库”,借助其功能丰富的库为开发人员提供了环境。
- DOM 操作: DOM 元素可以很容易地遍历、修改。
- 动画 动画的许多内置功能。
- HTML 事件处理和操作。
- Ajax 使用易于使用的 API 简单得多,该 API 可在多种浏览器上运行。
- CSS 操作
- 具有高级 UI 小部件库。
- 跨浏览器支持:在 Chrome、Opera 等浏览器上运行良好。
- 轻量级:只有 19kb 大小。
- 和其他公用事业
例子:
javascript
On clicking the "Hide_me" button, I will disappear.
输出:当我们点击 Hide_me 按钮时,上面标记的标题将消失,但只要我们点击 Shoe_me 按钮,它就会再次出现。
JavaScript 和 JQuery 之间的主要区别如下:
JavaScript | JQuery | |||
---|---|---|---|---|
1. | JavaScript uses JIT[Just in Time Compiler] which is combination of interpreter and Compile and is written in C. It’s a combination of ECMA script and DOM (Document Object Model). | While JQuery Uses the resources that are provided by JavaScript to make things easier. It is a light-weight JavaScript library. It has only the DOM. | ||
2. | JavaScript uses long lines of code as an individual has to write the code own-self. | With JQuery, one has to write fewer lines of code than JavaScript. We just need to import the library and use the only specific functions or methods of the library in our code. | ||
3. | In JavaScript, we have to write extra code or move around to have the with cross-browser compatibility. | JQuery has an inbuilt feature of cross-browser compatibility. We don’t need to worry about writing extra lines of code or move around in order to make our code compatible with any browser. | ||
4. | JavaScript can be a burden over a developer as it may take a number of lines of lengthy code to attain functionality. | Unlike JavaScript, JQuery is more user-friendly only a few lines of code have to write in order to have its functionality. | ||
5. | JavaScript is verbose because one has to write their own scripting code which is time-consuming. | JQuery is concise and one need not write much as scripting already exists. | ||
6. | Pure JavaScript can be faster for DOM selection/manipulation than jQuery as JavaScript is directly processed by the browser and it curtails the overhead which JQuery actually has. | JQuery is also fast with modern browsers and modern computers. JQuery has to be converted into JavaScript to make it run in a browser. | ||
7. | We can make animations in JavaScript with many lines of code. Animations are mainly done by manipulating the style of an Html page. | In JQuery, we can add animation effects easily with fewer lines of code. | ||
8. | JavaScript is a language, obviously, it would be heavier than JQuery. | While JQuery is a library, derived from JavaScript hence, it is lightweight. | ||
9. | JavaScript is an independent language and can exist on its own. | JQuery is a JavaScript library. It would not have been invented had JavaScript was not there. jQuery is still dependent on JavaScript as it has to be converted to JavaScript for the browser in-built JavaScript engine to interpret and run it. |
jQuery 是一个开源 JavaScript 库,它简化了 HTML/CSS 文档之间的交互,它以其“少写,多做”的理念而广为人知。
您可以按照此 jQuery 教程和 jQuery 示例从头开始学习 jQuery。