jQuery功能函数【一】

1.        $(document).ready(function(){

      // 代码部分

    });

文档载入完毕后执行代码

2.        Core

  jQuery(expression ,context)

  jQuery(html) 生成节点

  jQuery(elements) 元素的引用

  jQuery(callback)

  .each(callback) 循环调用

  .size() 计算 size

  .length 返回长度

  .eq(position)

  .get() 获取对象

  .get(index) 获取某个位置的对象

  .index(subject) 获取下标

  jQuery.fn.extend(objuect) 函数继承

  jQuery.extend(object) 对象继承

  jQuery.noConflict() 消除冲突

  jQuery.onConflict(extreme)

 

3.        Effects

  .show([speed],[callback])

  .hide([speed],[callback])  

  .toggle([speed],[callback]) 以指定速度交替显示隐藏,每次显示隐藏执行完后执行 callback 。 (speed 和callback 可选 )

  .slideDown([speed],[callback])           

  .slideUp([speed],[callback])   

  .slideToggle ([speed],[callback])   

  .fadeIn([speed],[callback])     

  .fadeOut([speed],[callback])  speed 也可以为整数,单位为秒

  .fadeTo([speed],[opacity],[callback])
  .animate(params,[duration],[easing],[callback])

  .animate(params,options)

  .stop()  停止动画

  .queue()

  .queue(callback)

  .queue(queue)

  .dequeue()

  Speed:”slow”,”normal”,”fast”

  Opacity: 透明度( 0~1 ) ;

  Callback: 回调函数,只执行一次

4.        .click(function(){

      // 代码部分

    });

5.        selectors

  $(“tagName”)        选择标签

  $(“#id”)                 “#” 选择 id
  $(“.className”)         “.”
 选择类

  从属关系; $(“tag1  tag2”)=$(“tag1>tag2”) 选择 tag1 中的 tag2

  跟随关系:     $(“tag1+tag2”) 选择 tag1 后面不属于任何组件的第一个 tag2             $(“tag1~tag2”) 选择tag1 后面不属于任何组件的所有 tag2

  1)       Basic Filters

    :first     如 $(“tr:first”) 指页面中所有 tr 中的第一个 tr

    :last     

    :not(selector) 如: tr:not(:first) 除第一个以外的所有

    :even 偶数               :odd 奇数   JS 由 0 起, CSS 由 1 起

    :eq(n) 第 n+1 个

    :gt(index)   :lt(index)    大于或小于某个 index 的对象

    :header      针对 h1 、 h2 、 h3 等 header 的选取

    :animated 正在动画的对象的选取

  2)       Content Filters :内容选取

    :contains(text) 包含某些文字的对象

    :empty 空的对象

         :has(selector) 与 :contains() 不同的是, :contains() 包含的是指内容,而这里包含的是指对象

  3)       Visibility Filters
    :hidden 
隐藏的对象的选取

    :visible 可见的对象的选取

  4)       Attributes Filters
    $(“tag[attri]”) 
有 attri 属性的 tag 。如: $(“p[id]”) 有 id 属性的 p 标签

    $(“tag[attri=’value’]”) 有 attri 属性且值为 value 的 tag

    $(“tag[attri!=’value’]”)      attri 属性不等于 value
    $(“tag[attri^=’value’]”)
 以 value 开头的 attri

    $(“tag[attri$=’value’]”) 以 value 结尾的 attri

    $(“tag[attri*=’value’]”) 包含 value 的 attri

    [selector1][selector2][selectorN]

  5)       子系对象的选取

    :nth-child(index)  由 1 开始

    :first-child 表示选取父系下的第一个子系对象。与 :first 的不同之处在于, :first 只选取一个对象,而:first-child 选取所有父系对象下的第一子系对象。如 $(“tr:first”) 指页面中所有 tr 中的第一个 tr ,只有一个,以 0 开始;而 $(“tr:first-child”) 指页面中所有 tr 的第一个子对象,可以有多个,以 1 开始

    :last-child 同 :first-child

    :only-child 仅有的唯一的子系对象被选取

  6)       窗体的选取 
    :input 代表 form 下的 input 、 textarea 、 select 和 button

    :text      input 内的类型为 text 的对象

    :password        :radio          :checkbox         :image

  7)       状态选取 
    :enabled     :disabled    :checked    :selected

6.        Attributes

  .attr(name) 获取 name 属性值

  .attr(properties)

  .attr({attribute:value}) 添加修改属性

  .attr(key,fn)

  .removeAttr(name)

  .addClass(class) 添加类

  .removeClass(class) 移除类

  .toggleClass(class)

  .html() 获取 html 值

  .html(val) 设定 html 值

  .text() 获取文本内容

  .text(val) 设定文本内容

  .val() 取窗体中域值

  .val(val) 设置窗体域值

posted on 2011-12-28 11:50  balabala已被注册  阅读(1121)  评论(0编辑  收藏  举报

导航