09.07 jQuery 随意整理
IE 兼容版本的寫法
<!--[if gt IE 8]> <!-->
?? ?<script src="../jquery-3.2.1.min.js"></script>
?? ?<!--<![endif]-->
?? ?<!--[if lte IE 8]>
?? ?<script src="../jquery-1.12.4.min.js"></script>
?? ?<![endif]-->
?
# jQuery 基礎
### ready 事件
*?用法
????????
????????$(document).ready(function(){
????????})
????????//簡寫
????????$(function(){
????????})
*?與onload的區別
????*??onload 事件 等到頁面的一切加載完畢,才能觸發
????*??ready事件等頁面中所有的dom加載完畢,就能觸發
### jquery dom 和 原生 dom
*?通過$() 獲取的對象,是jquery dom
*?jquery dom 本質上是由 原生dom 組成的集合,通過取下標就可以獲取原生dom
*?$()方法可以把 原生dom 變為 jquery dom??`$(document)`
### jquery 中綁定事件
# jquery 選擇器
### 基本選擇器
*?#ID
*?.className
*?tagName
*?*
*?selecter,selecter
### 層級選擇器
*?selecter seclter
*?selecter>selecter
*?selecter+selecter
*?selecter~selecter
### 過濾選擇器
*?:first
*?:last
*?:eq(index)
*?:lt(index)
*?:gt(index)
*?:odd?????奇數
*?:even????偶數
*?:not(selecter)??排除
*?:lang()
*?:header???所有的標題標簽(hn)
*?:root?
*?:target??
### 內容選擇器
*?:contains(text)
*?empty
*?parent
*?has(seelcter)
### 可見性選擇器
*?:hidden
*?:visible
### 屬性選擇器
*?[attrName]
*?[attrName=value]
*?[attrName!=value]
*?[attrName^=value]
*?[attrName$=value]
*?[attrName*=value]
### 子元素選擇器
*?:first-child
*?:last-child
*?:nth-child()
*?:nth-last-child()
*?:only-child
*?:first-of-type
*?:last-of-type
*?:nth-of-type()
*?:nth-last-of-type()
*?:only-of-type
### 表單選擇器
*?:input???所有的表單控件(input\select\textarea)
*?:text
*?:radio
*?:checkbox
*?:password
*?:image
*?:submit?
*?:reset
*?:button??
*?:file
### 表單對象選擇器
*?:diabled
*?:enable
*?:checked
*?:selected
# 篩選
### 過濾
*?.eq(index)
*?.first()
*?.last()
*?not(selcter)
*?filter(selecter)
*?has(selecter)
*?slice(start, end)
*?is(selecter)???????????true/false
*?hasClass(className)??/true/false
*?map(fn)???
### 查找
*?find(selcter)???????后代元素
*?children(selcter)???子元素
*?parent()???父元素
*?parents(selcter)??所有的祖先元素
*?parentsUntil(selecter)???所有祖先素直到
*?closest(selecter)??從自身和祖先元素中 找到第一個滿足條件
*?next()??
*?nextAll()
*?nextUntil()
*?prev()
*?prevAll()
*?prevUntil()
*?siblings()?????所有的兄弟元素???
### 串聯
?
?
09/08
?
### 串聯
*?add(selcter)????把選中的元素加入到當前集合
*?addBack()??????把最近的堆棧中元素加入當前集合
*?end()?????????????返回最近一次破壞性操作之前的元素
*?contents()?????所有子節點的集合(不是jquery dom)
?
?
# 屬性操作
### 屬性操作的方法
*?prop(attr [,val])???只能操作內置屬性
*?attr(attr [,va])?????操作自定義屬性
*?remvoeAttr(attr)??移除屬性
### class操作
*?addClass()???添加一個類
*?removeClass()???移除一個類
*?toggleClass() 切換
*?hasClass()????判斷一個類
### HTML代碼/文本/值
*?html([val])???
*?text([val])
*?val([val])
# CSS
### css方法
*?css()
### 位置
*?offset()????
*?postion()
*?scrollLeft([val])
*?scrollTop([val])
### 尺寸
*?width() / height()
*?innerWidth()??/ innerHeight()
*?outerWidth() / outerHeight()
# 文檔處理(添加刪除元素)
### 內部插入
*?append()
*?appendTo()
*?prepend()
*?prependTo()
### 外部插入
*?after()
*?insertAfter()
*?before()
*?insertBefore()
### 包裹
*?wrap()
*?wrapAll()
*?wrapInner()
*?unwrap()
### 替換
*?replaceWith()
*?replaceAll()
### 刪除元素
*?empty() 清空
*?remove() 刪除(自己)
*?detach()??刪除
### 克隆
*?clone()
# 事件
### ready
### 事件綁定方式
*?事件(fn)
*?bind("事件", fn)???指定對象 同時綁定多個事件
*?on("事件", fn)
*?one("事件", fn)
### 事件解除綁定
*?unbind()
*?off()
### 事件委派
*?on(事件, 選擇器, fn)
*?delegate(選擇器, 事件, fn)
*?undelegate(選擇器)???
### 自動觸發事件
*?trigger()???????
*?triggerHandler()
### jQuery 事件
*?hover
*?mouseenter
*?mouseleave
*?focusin
*?focusout
### 事件對象
?
09.11
# 效果
### 基本 (width/height/opacity)
*?show()
*?hide()
*?toggle()
### 滑動滑出 (height)
*?slideUp()???????隱藏
*?slideDown()??顯示
*?slideToggle()
### 淡入淡出
*?fadeOut()????隱藏
*?fadeIn()??????顯示
*?fadeToggle()
*?fadeTo()
### 自定義動畫 *?animate(params, speed, easing, fn) ### 動畫操作 *?stop() *?finish() *?delay()??延遲 # 工具 ### 瀏覽器 *?$.support ### 對象和屬性操作 *?$.each() *?$.extend() # 核心 ### jQueryDOM 方法 *?each() *?size() *?length
轉載于:https://www.cnblogs.com/lwwnuo/p/7489790.html
總結
以上是生活随笔為你收集整理的09.07 jQuery 随意整理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html5 填表 表单 input ou
- 下一篇: ABP文档翻译--值对象