オブジェクトへ命令すること

オブジェクト(部品)に対して動作を指定します。 オブジェクト毎にメソッドが用意されており、ピリオド(.)で区切って、オブジェクト.メソッド(値) の順で記述します。
たとえば、HTMLファイル内に内容を書き出すことができる write( ) メソッドを使いたい場合は document.write(値); と記述します。

document.getElementById("idの名前を入れる")

・・・ドキュメントにある特定のIDを持つオブジェクトを示します


【 JavaScript 】
window.onload=function(){
	document.getElementById("photo1").onmouseover=function(){
		this.src="images/02.jpg";
	}
	document.getElementById("photo1").onmouseout=function(){
		this.src="images/01.jpg";
	}
}

読み込んだ時、id名photo1の画像をマウスが乗ったら、02.jpgの画像に変更する。
マウスが離れたら、id名photo1の画像を、01.jpgの画像に変更する。


【 HTML 】
<img src="images/01.jpg" id="photo1" />

単体のロールオーバー


<a href="http://myanmar-isami.com"><img src="./image/button/btm01.gif" alt="トップページ" width="137" height="51" onMouseOver="this.src='./image/button/btm001.gif'" onmouseout ="this.src='./image/button/btm01.gif'" /></a>