Rabu, 27 November 2013

Contoh Document Object Model


Contoh Penggunaan DOM
 
<html>
<head>
<title>
DOM </title>
</head>
<body>
<div>

<span id="satu">
Hallo Kalbis Institute
</span>
<span>
<font color
="red"> </font>
</span>
</div>
<script type
="text/javascript">
alert(document.getElementById("satu"));
</script>
</body>
</html>

Contoh Penggunaan DOM dalam web

<html>
<body>
<script>
function gantiGambar()
{
element=document.getElementById('gambarku')
if (element.src.match("bulbon"))
{
element.src="gambar_flora.gif";
}
else
{
element.src="gambar_fauna.gif";
}
}
</script>
<img id="gambarku" onclick="gantiGambar()" border="0" src="gambar_flora.gif" width="100" height="180">
<p>Klik yang ini</p>

</body>
</html>


Tidak ada komentar:

Posting Komentar