[jquery] Form Reset 방법
– $(“#formName”).reset(); or $(“form”).reset(); — 작동하지 않음
1. 특정 form reset
// 첫번째 form reset
$(document).ready(function() {
$("#btnReset").click(function() {
$("form")[0].reset();
});
});
// 특정 id form reset
$(document).ready(function() {
$("#btnReset").click(function() {
$("form").each(function() {
if(this.id == "frmId") this.reset();
});
});
});
// 특정 class form reset
$(document).ready(function() {
$("#btnReset").click(function() {
$("form").each(function() {
if(this.className == "frmClass") this.reset();
});
});
});
2. 전체 form reset
$(document).ready(function() {
$("#btnReset").click(function() {
$("form").each(function() {
this.reset();
});
});
});