使用动态id重置窗体



表单如下所示:

<form id="yui_3_17_2_1_1533233239059_403"><input placeholder="Type to search…" type="text" spellcheck="false" value="boy" id="yui_3_17_2_1_1533233239059_402"></form>

ID是动态的。页面加载后,我需要清除其输入文本。

不知道如何确定动态ID的ID。

$(".reset").click(function() {
$(this).closest('form').find("input[type=text], textarea").val("");
});

我认为这样的东西可以被改编。

如果这是页面中唯一的表单,那么它就很简单:

$(".reset").click(function() {
$('form')[0].reset();
});

最新更新