jQuery API | jQuery API 中英文对照版 - jQuery在线查询手册 |
get(num) |
get(num)
取得其中一个匹配的元素。 num表示取得第几个匹配的元素。 返回值:Element 参数:
选择文档中所有的图像,并返回第一个。 HTML 代码: <img src="test1.jpg"/> <img src="test2.jpg"/> jQuery 代码: $("img").get(0); 结果: [ <img src="test1.jpg"/> ] Access a single matched DOM element at a specified index in the matched set. This allows you to extract the actual DOM element and operate on it directly without necessarily using jQuery functionality on it. Return value: Element
Example: Selects all images in the document and returns the first one $("img").get(0);Before: <img src="test1.jpg"/> <img src="test2.jpg"/>Result: <img src="test1.jpg"/> |