Objek Skrip DOM HTML
Objek Skrip
Objek Script mewakili elemen <script> HTML.
Mengakses Objek Skrip
Anda dapat mengakses elemen <script> dengan menggunakan getElementById():
Contoh
var x = document.getElementById("myScript");
Tip: Anda juga dapat mengakses elemen <script> dengan menggunakan kumpulan skrip .
Buat Objek Skrip
Anda dapat membuat elemen <script> dengan menggunakan metode document.createElement() :
Contoh
var x = document.createElement("SCRIPT");
Properti Objek Skrip
Property | Description |
---|---|
async | Sets or returns whether a script should be executed asynchronously as soon as it is available |
charset | Sets or returns the value of the charset attribute of a script |
crossOrigin | Sets or returns the the CORS settings of a script |
defer | Sets or returns whether a script should be executed when the page has finished parsing |
src | Sets or returns the value of the src attribute of a script |
text | Sets or returns the contents of all the text nodes that are children of a script |
type | Sets or returns the value of the type attribute of a script |
Properti dan Acara Standar
Objek Script juga mendukung properti dan event standar .
Halaman Terkait
Referensi HTML: tag HTML <script>