JQuery 버튼 비활성화

1 개요[ | ]

jQuery 버튼 비활성화

.prop() 또는 .attr() 메소드로 비활성화 가능

// 비활성화
obj1.prop("disabled", true);
obj1.attr("disabled","disabled");

// 활성화
obj2.prop("disabled", false);
obj2.removeAttr("disabled");

2 예제 1[ | ]

<script src="//code.jquery.com/jquery.min.js"></script>
<script>
  $(function() {
    $("#btn-hello")
      .click(function() { alert("Hello"); });
    $("#btn-world")
      .click(function() { alert("World"); })
      .prop("disabled", true);
  });
</script>
<button id="btn-hello">Say Hello</button>
<button id="btn-world">Say World</button>

3 예제 2[ | ]

<script src="//code.jquery.com/jquery.min.js"></script>
<script>
  $(function() {
    $("#btn-hello")
      .click(function() { alert("Hello"); });
    $("#btn-world")
      .click(function() { alert("World"); })
      .attr("disabled","disabled");
  });
</script>
<button id="btn-hello">Say Hello</button>
<button id="btn-world">Say World</button>

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}