더 나은 프로그래머가 되자

form reset 폼 리셋 본문

언어/js

form reset 폼 리셋

greathuman 2014. 2. 18. 11:43

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();
   });
 });
});

 

출처 : http://rocabilly.tistory.com/30 

'언어 > js' 카테고리의 다른 글

jquery stop() 함수 (애니메이션 멈추기)  (0) 2014.02.21
jquery onchange 처리  (0) 2014.02.18
탑메뉴 고정 jquery  (0) 2013.06.13
탑메뉴 고정 jquery  (0) 2013.06.13
setInterval,clearInterval  (0) 2013.06.12
Comments