Kaedah HTML DOM Element contains()
- Previous Page compareDocumentPosition()
- Next Page contentEditable
- Go to Previous Level Objek Elements DOM HTML
Definisi dan penggunaan
Jika nod adalah turunan nod lain, contains()
Kembalian kaedah true
.
Jika bukan,contains()
Kembalian kaedah false
.
Keterangan:Turunan boleh termasuk anak, cucu, cicit …
Contoh
Adakah "mySPAN" adalah turunan "myDIV"?
const span = document.getElementById("mySPAN"); let answer = document.getElementById("myDIV").contains(span);
Sintaks
nod.contains(nod)
Parameter
Parameter | Deskripsi |
---|---|
nod | Diperlukan. Nod yang boleh termasuk turunan nod ini. |
Kembalian
Jenis | Deskripsi |
---|---|
Bulan | true - nod adalah turunan false - nod adalah turunan
Pendukung pelayar
element.contains()
Adalah fitur DOM Level 1 (1998).
Semua pelayar web mengesahkan penuhnya:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | 9-11 | Support | Support | Support | Support |
- Previous Page compareDocumentPosition()
- Next Page contentEditable
- Go to Previous Level Objek Elements DOM HTML