Javascript 獲取多個(gè)form表單數(shù)據(jù)第三方:
form-serialize
具體使用:
<form id="example-form">
<label for="username">用戶名:</label>
<input type="text" name="username" value="shiwensong" /> <br />
<label for="username">密碼:</label>
<input type="password" name="password" value="12345678" /><br />
</form>
<button>提交</button>
<script src="./form-serialize.js"></script>
<script>
document.querySelector("button").addEventListener("click", function (event) {
var form = document.querySelector('#example-form');
var obj = serialize(form, { hash: true, empty: true });
console.log(obj)
})
</script>