"JQuery 버튼 비활성화"의 두 판 사이의 차이

17번째 줄: 17번째 줄:
<script src="//code.jquery.com/jquery.min.js"></script>
<script src="//code.jquery.com/jquery.min.js"></script>
<script>
<script>
   $(function() {
   $("#btnAjaxClick").click(function() {
    $("#btn-hello")
              $.ajax({
      .click(function() { alert("Hello"); });
                  uri: "ead/test",
    $("#btn-world")
                  type: "post",
      .click(function() { alert("World"); })
                  data: "parameter=" + $(this).data("parameter"),
      .prop("disabled", true);
                  success: function(result) {
                    () $(this).prop("disabled", true);
                }
        })});
   });
   });
</script>
</script>

2019년 6월 20일 (목) 15:00 판

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>
  $("#btnAjaxClick").click(function() {
              $.ajax({
                  uri: "ead/test",
                  type: "post",
                  data: "parameter=" + $(this).data("parameter"),
                  success: function(result) {
                     () $(this).prop("disabled", true);
                 }
         })});
  });
</script>
<button id="btn-hello">Say Hello</button>
<button id="btn-world">Say World</button>
<body>
     <button id="btnAjaxClick">Click me</button>
     <script>
         $("#btnAjaxClick").click(function() {
             $.ajax({
                 uri: "ead/test",
                 type: "post",
                 data: "parameter=" + $(this).data("parameter"),
                 success: function(result) {
                    (가) $(this).prop("disabled", true);
                }
        })});
    </script>
</body>

3 같이 보기

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