如何使用JavaScript/jQuery獲取表單數據?是否有一種簡單的、單行的方法來獲取表單的數據,就像它將以傳統的HTML方式提交一樣?例如,在:<form>
<input type="radio" name="foo" value="1" checked="checked" />
<input type="radio" name="foo" value="0" />
<input name="bar" value="xxx" />
<select name="this">
<option value="hi" selected="selected">Hi</option>
<option value="ho">Ho</option></form>退出:{
"foo": "1",
"bar": "xxx",
"this": "hi"}這樣的內容太簡單了,因為它沒有(正確地)包括文本區域、選擇、單選按鈕和復選框:$("#form input").each(function() {
data[theFieldName] = theFieldValue;});
如何使用JavaScript/jQuery獲取表單數據?
九州編程
2019-07-15 09:50:37
