onfocusイベント

onblurイベント

イベントを設定していないテキストボックス


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>フォーカスを得た時や失った時に処理したい</title>
</head>
<body>
<form name="myForm">
<h2>onfocusイベント</h2>
<p><input type="text" name="myText1" value="ここを選択するとonfocusが発生する" size="50" onfocus="alert('フォーカスを得るとonfocusイベントが発生する')"><p>
<h2>onblurイベント</h2>
<p><input type="text" name="myText2" value="ほかの場所を選択するとonblurが発生する" size="50" onblur="alert('フォーカスを失うとonblurイベントが発生する')"></p>
<h2>イベントを設定していないテキストボックス</h2>
<p><input type="text" name="myText3" value="イベントなし" size="50"></p>
</form>

</body>
</html>


onfocusイベント

onblurイベント

イベントを設定していないテキストボックス

★解説★