<?php
if($_POST) {
print_r($_POST);
exit;
}
?>
<script src="bootstrap/js/jquery.js"></script>
<script>
$(function() {
//在 form 标记中就这样
$.post(location, $('form').serialize(), function(d) {alert(d)});
// 不在 form 标记中就这样
d = {};
$("input[name^='sort']").each(function(i, el) {
d[el.name] =$(this).val();
});
$.post(location, d, function(d) {alert(d)});
});
</script>
<form>
<input type="text" name="sort[1]" value="1" />
<input type="text" name="sort[2]" value="2" />
<input type="text" name="sort[3]" value="3" />
</form>
jquery 获取 input 名为数组
最新推荐文章于 2021-10-05 21:24:01 发布