jQuery 核心函式和工具方法

2021-10-07 06:20:10 字數 1082 閱讀 1529

接收乙個dom元素: 會被包裝成乙個jquery物件返回給我們

var span = document.

getelementsbytagname

('span')[

0];console.

log(

'span>>>'

, span)

var $span =

$(span)

;console.

log(

'$span>>>'

, $span)

原生foreach方法遍歷陣列

var arr =[1

,2,3

,4,5

,6]var obj =

/* - index: 當前遍歷到的索引

- value: 遍歷到的元素

*/arr.

foreach

(function

(value, index)

)// 報錯

// obj.foreach(function(value, index))

處理陣列

原生js的map方法:

var arr =[1

,2,3

,4,5

,6]var obj =

/*value: 當前遍歷元素

index: 當前遍歷到的索引

array: 當前被遍歷的陣列

*/arr.

map(

function

(value, index, array)

)// 報錯

// obj.map(function (value, index, array) )

// 返回值:true/false

var resfun = $.

isfunction

(jquery)

console.

log(

'isfunction>>>'

, resfun)

jQuery工具和方法

jquery方法和工具 1.each 遍歷陣列或物件中的資料 var obj json物件 json物件 js物件 console.log parsejson json json json陣列 json陣列 js陣列 console.log parsejson json json.parse jso...

JQuery核心函式和靜態方法

首先,搞清楚靜態方法和例項方法的區別 靜態方法是直接在類上新增,通過引用類名呼叫。例 1.定義乙個類 function aclass 2.給這個類新增靜態方法 直接新增給類的就是靜態方法 aclass.staticmethod function 3.靜態方法通過類名呼叫 aclass.staticm...

jQuery核心函式

jquery核心函式 1.jquery expression,context 返回值 jquery 這個函式接收乙個包含 css 選擇器的字串,然後用這個字串去匹配一組元素。示例 找到所有 p 元素,並且這些元素都必須是 div 元素的子元素。html one two three jquery di...