ロードした時、指定した ID(テキストエリア)にフォーカスする JavaScript サンプルです。 わざわざ、関数にしなくても出来た様な気がする…。
実際に動作するサンプル
https://codepen.io/darucub/pen/LENxZrL
サンプルコード
<html>
<head>
<title>指定した ID にフォーカスするサンプル</title>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<script language="javascript">
<!--
function setFocus (id) { document.getElementById(id).focus();
}
//-->
</script>
</head>
<body onLoad="JavaScript:setFocus('test');">
<form>
<input type="text">
<input type="text">
</form>
</body>
</html>現場からは以上です。それでは、またッ!!!
