jQuery学习-------认识jQuery

2023-06-15,,


jQuery 是一个“写的更少,但做的更多”的轻量级 JavaScript 库。

jQuery安装

   方法1:将jQuery文件放置在本地,通过script标签引入;

   方法2:使用Google在线提供的库文件,

          <script type="text/javascript" src="http://ajax.lug.ustc.edu.cn/ajax/libs/jquery/1.6.4/jquery.min.js " ></script>

         

          还可以使用google提供的API导入:

          <script type="text/javascript" src="http://www.google.com/jsapi  "></script>

          <script type="text/javascript">

           google.load("jquery","1.6.4",{uncompressed:true});

          </script>

测试jQuery:

 <script type="text/javascript">
   $(function(){
   	alert("hello!");
   })   
 </script>

解释: $ 是jQuery的别名,$()等价于jQuery()

      jQuery()函数是jQuery库文件的接口函数,所有jQuery操作都必须从该接口函数切入。

      jQuery()函数相当于页面初始化事件处理函数,当页面加载完成后,会执行jQuery()函数中包含的函数。

jQuery框架的优势:

  1. 体积小,使用灵活;      

  2. 丰富的DOM选择器

  3. 跨浏览器

  4. 链式代码

  5. 强大的事件、样式支持

  6. 强大的Ajax功能

  7. 易于扩展、插件丰富

jQuery框架的核心功能:

  1. 对外接口单一

    jQuery把所有的操作都封装在一个jQuery()函数中,形成统一的操作入口。

    jQuery()能解析的主要参数有:

       jQuery(expression,context);

       jQuery(html);

       jQuery(elements);

       jQuery(fn);

  2. 链式语法

  3. 模仿CSS选择器

  4. 扩展接口


《jQuery学习-------认识jQuery.doc》

下载本文的Word格式文档,以方便收藏与打印。