1. 程式人生 > >js 原生代碼找對象的方法

js 原生代碼找對象的方法

image this element eve 查詢 bsp AS html標簽 ()

1. id : document.getElementById(‘id‘)

2. 標簽 : document.getElementsByTagName(‘標簽‘) //獲得的是一個標簽數組

3. Name :document.getElementsByName(‘name名‘) // 該方法與 getElementById() 方法相似,但是它查詢元素的 name 屬性,而不是 id 屬性

4. className:document.getElementsByClassName(‘class‘) //獲得一個class的數組

5.document.images : 獲得img對象//獲得數組

6.document.links : 獲得所有的鏈接//獲得數組

7.document.forms:獲得表單對象// 獲得數組

8.document.body: body 標簽對象

9.document.documentElement :html標簽對象

10. event: 事件對象

11. this :當前對象

js 原生代碼找對象的方法