js createElement 隐藏域

如何用js createElement 创建隐藏域 ???

<html>

<head>

<script type="text/javascript">
function a(){
var input = document.createElement("input");
input.type = 'hidden';
input.name = 'hiddenInput';
document.getElementById("testForm").appendChild(input);
}
</script>
</head>

<body onload="a();">
<div id='test'>
<form id='testForm'></form>
</div>
</body>
<html>

创建一个input元素,把他的type属性设成hidden就是创建了一个隐藏域。
温馨提示:答案为网友推荐,仅供参考