1.加載完成
$(document).ready(function(){});
$(window).ready(function(){});
$(this).ready(function(){});
$(function(){});
2.jQuery對象的屬性和方法
size() : dom的個數(shù)
html() : 獲得內(nèi)部html
html(“html”) : 設(shè)置html
length : dom的個數(shù)
each(function(index,obj)) : 遍歷
get(index) : 根據(jù)索引獲得元素
innerHTML : 獲得內(nèi)部html
val() : 取值
val(“txt”) 設(shè)置值
text() : 獲得文本內(nèi)容
text(“txt”) : 設(shè)置文本內(nèi)容
attr(“name”) : 獲得屬性值
attr(“name”,”value”) : 設(shè)置屬性值
empty() : 清空子元素
trim() : 去掉字符串首尾空格
focus(function(){}) : 獲得焦點時調(diào)用
click(function(){}) : 點擊事件
3.dom 轉(zhuǎn) jQuery 對象
$(dom)
4.jQuery 轉(zhuǎn) dom 對象
5.選擇器
$(“#id”) : id選擇器
$(“.class”) : class選擇器
$(“標(biāo)簽名”) : 標(biāo)簽選擇器
6.層級選擇器
$(“parent child”) : 后代選擇器
$(“parent > child”) : 后代元素
$(“pre + next”) : 后邊下一個元素
$(“pre ~ sub”) : 后邊所有的元素
7.過濾選擇器
:first $(“div:first”)
:last $(“div:last”)
:even : 獲得偶數(shù)元素
:odd : 獲得奇數(shù)元素
:eq(index) : 獲得索引為index的元素
:gt(index) : 獲得 index - 最后的元素
:lt(Index) : 獲得0-index的元素
:header : 獲得h1,h2這種標(biāo)題元素
:animated : 獲得動畫的元素
:not(selector) :獲得取出selector的元素
8.內(nèi)容過濾器
:contains(‘text’) : 內(nèi)容包含選擇器
:empty 空內(nèi)容
:has(selector) 有某種元素的選擇器
:parent 有父元素的選擇器
9.可見性選擇器
:hidden 不可見的
:visible 可見的