get() and eq() 區(qū)別
為什么用get()就可以寫成JS的樣子:$("#aaron a").get(4).style.color="#fff"; ? ? ? 而用eq()就不能寫成這樣子呢:$("#aaron a").eq(4).style.color="#fff"; ? ? ? ? ? eq()一定要寫成這樣子才有效果嗎?:$aaron.eq(3).attr("style","color:#fff;");
為什么用get()就可以寫成JS的樣子:$("#aaron a").get(4).style.color="#fff"; ? ? ? 而用eq()就不能寫成這樣子呢:$("#aaron a").eq(4).style.color="#fff"; ? ? ? ? ? eq()一定要寫成這樣子才有效果嗎?:$aaron.eq(3).attr("style","color:#fff;");
2016-05-22
舉報(bào)
2017-09-14
看了各位大神的評(píng)論,總算理解了.
2016-10-29
等價(jià)于:
注意區(qū)分返回對(duì)象的不同
2016-09-14
eq() 返回的是jquery對(duì)象,get()返回的是dom元素。jquery對(duì)象封裝了自己的屬性和方法,dom對(duì)象也同樣,二者的方法不能混用。
$aaron.eq(1).css("color","blue") ? ??
? $aaron.get(1).style.color = "blue"
2016-07-08
eq返回的是一個(gè)jQuery對(duì)象,get返回的是一個(gè)DOM對(duì)象,
用法可以參考一下:
????$aaron.eq(1).css("color","blue") ? ??
????$aaron.get(-2).style.color = "#8A2BE2"
這個(gè)里面有很詳細(xì)的解答:
????http://idcbgp.cn/code/3416
2016-06-26
eq() 返回的是jquery對(duì)象,get()返回的是dom元素。
2016-05-23
eq() 返回的是jquery對(duì)象,get()返回的是html數(shù)組。jquery對(duì)象,沒有style。