2 Contoh Penggunaan Properti lastElementChild DOM pada HTML
Sintak:
element.lastElementChild
<!DOCTYPE html>
<html>
<head>
<title>
Properti lastElementChild DOM
</title>
<!-- script untuk menemukan
elemen child terakhir -->
<script>
function Bons()
{
var doc =
document.getElementById("MKN").lastElementChild.innerHTML;
document.getElementById("p").innerHTML = doc;
document.getElementById("p").style.color = "white";
document.getElementById("p").style.background = "green";
}
</script>
</head>
<body style="text-align: center;">
<h1 style="color:green;">
Blog Elfan
</h1>
<h2>
Properti lastElementChild DOM
</h2>
<div id="MKN">
<span>
Blog TIK!
</span>
<span>
Portal Ilmu Komputer.
</span>
</div>
<br>
<button onclick="Bons()">
Click me!
</button>
<p id="p"></p>
</body>
</html>
Jenis browser apa saja yang dapat digunakan untuk mengaktifkan properti lastElementChild() DOM pada HTML?
BalasHapusBerikut adalah beberapa jenis browser yang dapat digunakan untuk mengaktifkan properti lastElementChild() DOM pada HTML:
Hapus1. Google Chrome 2.0
2. Internet Explorer 9.0
3. Firefox 3.5
4. Opera 10.0
5. Safari 4.0
Apa fungsi dari properti lastElementChild() DOM pada HTML?
BalasHapusProperti lastElementChild DOM pada HTML berfungsi untuk mengembalikan elemen child terakhir dari suatu elemen. Properti ini bersifat read-only.
HapusProperti read-only Element.lastElementChild berfungsi untuk mengembalikan elemen anak terakhir dari suatu elemen, atau mengembalikan nilai null jika tidak ada elemen anak apapun yang ditemukan.
Hapus