Home > Web Front-end > JS Tutorial > How to use JQuery framework in js

How to use JQuery framework in js

php中世界最好的语言
Release: 2018-06-04 17:51:51
Original
2768 people have browsed it

This time I will show you how to use the JQuery framework in js, and what are the precautions when using the JQuery framework in js. The following is a practical case, let's take a look.

jQuery is a fast and concise JavaScript framework, is another excellent JavaScript code library after Prototype (or JavaScript framework). The purpose of jQuery's design is to advocate writing less code and doing more things. It encapsulates commonly used functional codes in JavaScript, provides a simple JavaScript design pattern, optimizes HTML document operations, event processing, animation design and Ajax interaction, greatly simplifying JavaScript programming . The core features of jQuery can be summarized as follows: It has a unique chain syntax and a short and clear multi-functional interface; it has an efficient and flexible css selector, and can extend the CSS selector ; Has a convenient plug-in extension mechanism and rich plug-ins. jQuery is compatible with various mainstream browsers, such as IE6.0, FF1.5, Safari2.0, Opera9.0, etc.

JQuery installation steps:

1. Download the corresponding file library (each A JQuery file library of the same version is divided into two, one is the uncompressed version, the source code can be viewed, used during development, (jquery-3.3.1.js)

One is a compressed version, with comments and spaces deleted, and the number of variable characters reduced. It will be used when the product is launched (jquery-3.3.1.min.js) with min one GeneralWe use this)

(http://jquery.com/ Downloadable)

2. Copy the JQuery JS file to the WEB directory (place it in the created web page directory)

3. The page references the js file (JQuery’s JS)

        <script type="text/javascript" src="js/jquery-3.3.1.js"></script>
Copy after login

4. Load JQuery into the page

(The above script only references jQuery, you can only write a script if you want to load JQuery)

There are three methods:

First type:

$(document).ready(function(){  
func(xxx)//执行函数
                       });  
//.ready函数是当DOM(文档对象模型)已经加载,并且页面(包括图像)已经完全呈现时,会发生ready事件,为了防止文档在完全加载(就绪)之前运行 jQuery 代码。
Copy after login

Second type:

$(function(){  
     func(xxx)//执行函数
             });
Copy after login

第三种:

jQuery(function($) {  
     func(xxx)//执行函数
                  });
Copy after login

基本语法:

$(selector).action()
Copy after login

美元符号定义JQuery

选择符(selector)"查询"和“查找” HTML元素

JQuery的action()执行对元素的操作

        <script type="text/javascript">
		$(function(){
			alert("helloWorld");
		})
	</script>
Copy after login

相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

推荐阅读:

filter怎样全局使用

如何获取dom内class的值

The above is the detailed content of How to use JQuery framework in js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template