jQuery.fn.extend ()

jQuery.fn.extend ()


설명 : 객체의 내용을 jQuery 프로토 타입에 병합하여 새로운 jQuery 인스턴스 메소드를 제공합니다.

이 jQuery.fn.extend()메소드는 jQuery prototype ( $.fn) 객체를 확장 하여 jQuery()함수에 연결될 수있는 새로운 메소드를 제공한다 .
예:
두 개의 메소드를 jQuery prototype ( $.fn) 객체에 추가 한 다음 그 중 하나를 사용하십시오.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery.fn.extend demo</title>
  <style>
  label {
    display: block;
    margin: .5em;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
 
<label><input type="checkbox" name="foo"> Foo</label>
<label><input type="checkbox" name="bar"> Bar</label>
 
<script>
jQuery.fn.extend({
  check: function() {
    return this.each(function() {
      this.checked = true;
    });
  },
  uncheck: function() {
    return this.each(function() {
      this.checked = false;
    });
  }
});
 
// Use the newly created .check() method
$( "input[type='checkbox']" ).check();
</script>
 
</body>
</html>

|

댓글 2개

신고가 접수되어 자동으로 블라인드 된 댓글입니다. 원문을 보시려면 를 클릭하세요.

댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
웹서버 8년 전 조회 6,364
PHP 8년 전 조회 5,891
jQuery 8년 전 조회 3,401
jQuery 8년 전 조회 2,335
jQuery 8년 전 조회 2,971
MySQL 8년 전 조회 3,133
jQuery 8년 전 조회 2,471
jQuery 8년 전 조회 2,697
jQuery 8년 전 조회 4,430
PHP 8년 전 조회 4,363
jQuery 8년 전 조회 4,153
jQuery 8년 전 조회 2,784
jQuery 8년 전 조회 2,299
jQuery 8년 전 조회 2,428
jQuery 8년 전 조회 3,183
jQuery 8년 전 조회 3,008
jQuery 8년 전 조회 2,368
jQuery 8년 전 조회 1,688
jQuery 8년 전 조회 2,602
jQuery 8년 전 조회 2,443
jQuery 8년 전 조회 2,277
jQuery 8년 전 조회 2,197
jQuery 8년 전 조회 1,907
jQuery 8년 전 조회 1,990
jQuery 8년 전 조회 2,116
jQuery 8년 전 조회 2,286
jQuery 8년 전 조회 2,474
jQuery 8년 전 조회 2,723
jQuery 8년 전 조회 1,903
jQuery 8년 전 조회 2,885