要素を作成するには、document.createElement(要素) と記述します。
戻り値が要素オブジェクトになります。
input要素の場合、属性はtypeやvalueなどがあります。
id属性=nobに追加していきます。この要素を取得するには
document.getElementByIdを使用します。
例えば、以下のボタンを押すとボタンを作成します。10個以上は作成できないようにしています。
<html>
<head>
<title></title>
<script type="text/javascript">
<!--
function make(){
if(document.all.tags("input").length != 11){
button = document.createElement("input");
button.type = "button";
button.value = "test" + document.all.tags("input").length;
document.getElementById("nob").appendChild(button);
}else{
alert("10個以上作成できません");
}
}
// -->
</script>
</head>
<body>
<input type="button" value="ボタン作成" onclick="make()">
<p id="nob"></p>
</body></html>