我有这个表格:
<form name="dateChooser" id="dateChooser">
<select name="chooseMonth" id="calChooseMonth">...</select>
<select name="chooseYear" id="calChooseYear">...</select>
</form>
因此,在更改 #calChooseMonth/#calChooseYear 时,我将 (this.form) 作为参数传递给函数。控制台日志记录(this.form)给了我这个:
<form name="dateChooser" id="dateChooser">
<select name="chooseMonth" id="calChooseMonth">...</select>
<select name="chooseYear" id="calChooseYear">...</select>
</form>
我试图在表单之外传递相同的表单数据,所以我不能使用“this”。我试过:
console.log($("form[name='dateChooser']"));
这会返回表单内容的客观数组,这可以工作,但我将数据发送到的函数是第三方,并且需要格式为的数据
console.log($('#dateChooser').html());
返回与我的(this.form)返回不匹配的原始html
console.log($('#dateChooser').form);
返回 undefined 不是一个函数。有点希望事情就这么简单。
最佳答案
关于javascript - 模仿表单之外的表单元素的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25068093/