gpt4 book ai didi

jquery - 如何用jquery更改属性替换表单中的提交?

转载 作者:行者123 更新时间:2023-12-01 06:34:57 26 4
gpt4 key购买 nike

伙计们,我有这个样本表格:

<form method="POST" action="/some/url/method-to-handle-the-form">
some stuff here.

<input type="submit">
</form>

原来的功能是需要单击提交按钮来加载该操作,我想做的是让它自动添加此选择类型:

<select blah blah>

每当我在其中选择某些内容时,表单就会与我选择的选项一起提交。

最佳答案

.closest()

DEMO

$('#selectElementId').change(
function(){
$(this).closest('form').trigger('submit');
/* or:
$('#formElementId').trigger('submit');
or:
$('#formElementId').submit();
*/
});

关于jquery - 如何用jquery更改属性替换表单中的提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18526084/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com