3 回答

TA貢獻1911條經驗 獲得超7個贊
我想了解jQuery對象和DOM元素之間的關系。
還有什么方法可以對jQuery對象和DOM元素進行操作?一個jQuery對象可以表示多個DOM元素嗎?
.get()
$("selector")[0] // Accesses the first DOM element in this jQuery object
$("selector").get(0) // Equivalent to the code above
$("selector").get() // Retrieve a true array of DOM elements matched by this selector
<div id="foo"></div>alert($("#foo")[0]); alert($("#foo").get(0)); alert(document.getElementById("foo"));
.get()

TA貢獻1982條經驗 獲得超2個贊
getElementById
var jQueryCollection = $("div"); //Contains all div elements in DOM
var normalCollection = document.getElementsByTagName("div");
div
get
var div1 = jQueryCollection.get(0); //Gets the first element in the collection

TA貢獻1803條經驗 獲得超3個贊
Functions
jQuery Object
jQuery Object
.
console.log("(!!) jquery >> " + $("#id") ) ;
[object Object]
jQuery Object
String
("#id"
Document
,
console.log("(!!) getElementById >> " + document.getElementById("id") ) ;
[object HTMLDivElement]
[object Object]
div
Element
.
還有什么方法可以對jQuery對象和DOM元素進行操作?(1)一個jQuery對象可以表示多個DOM元素嗎?(2)
Function
Object
Function
Node
jQuery Object
Element
Functions
jQuery.find
jQuery.each
- 3 回答
- 0 關注
- 585 瀏覽
添加回答
舉報