画面の各部分をクリックしてイベントを確認してみてください。。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>イベントメソッド内のthis</title> <link href="/gudon/css/default.css" rel="stylesheet" type="text/css" /> <link href="/gudon/rd/ajax/html/form1_this.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>イベントメソッド内のthis</h1> <hr /> <p>画面の各部分をクリックしてイベントを確認してみてください。。</p> <!-- thisはform1を示す --> <form id="form1" name="form1" onclick="alert(this.name);"> <!-- thisはtextbox1を示す --> <input name="textbox1" type="text" value="テキストボックス1" onclick="alert(this.name);"/> <input name="textbox2" type="text" value="テキストボックス2"/> <!-- this.formはtextbox1を含むformを示す --> <input name="button1" type="button" value="ボタン1" onclick="button1_onclick(this.form);"/> </form> <!-- thisはdivを示す --> <div id="div1" onclick="alert(this.innerHTML);"> div </div> <script type="text/javascript"> document.form1.textbox2.onclick=function(){ // thisはtextbox2を示す alert(this.name); } function button1_onclick(form1){ alert(form1.textbox1.value); } </script> </body> </html>