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>
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 代码。
Second type:
$(function(){ func(xxx)//执行函数 });
第三种:
jQuery(function($) { func(xxx)//执行函数 });
基本语法:
$(selector).action()
美元符号定义JQuery
选择符(selector)"查询"和“查找” HTML元素
JQuery的action()执行对元素的操作
<script type="text/javascript"> $(function(){ alert("helloWorld"); }) </script>
相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读:
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!