我只是練習一些JavaScript,我曾經使用JQuery很多!我沒有與原始JavaScript的主要經驗,我想學習它,就像我沒有JQuery。我有一個簡單的表單和一個JavaScript函數去與它onsubmit和我想獲得名稱和每個輸入的值與我的函數的形式,但它似乎並沒有工作有人可以幫我嗎?JavaScript的foreach輸入形式的名稱和值
<!DOCTYPE html>
<html>
<head>
<title>Foreach Practice</title>
<script type="text/javascript">
function Get() {
var Form = document.getElementById('Form');
for(I = 0; I < Form.length; I++) {
var Value = this.attribute('name').value;
alert(Value);
}
}
</script>
</head>
<body>
<form id="Form" onsubmit="return false;">
<input type="text" name="User" placeholder="Username" />
<input type="password" name="User" placeholder="Password" />
<input type="submit" name="Submit" onclick="javascript:Get();" />
</form>
</body>
</html>
這也是工作! – 2013-04-08 01:40:37
OP需要表單控件,* children *集合將獲得所有元素子元素,並且不會在所有使用的瀏覽器中實現。應該解決的代碼還有很多其他問題。 – RobG 2013-04-08 01:53:42