Jam's story

[JQuery] $.fn= jQuery.fn = jQuery.prototype 본문

WEB/JQuery

[JQuery] $.fn= jQuery.fn = jQuery.prototype

애플쩀 2022. 6. 14. 09:48

jquery-3.6.0.js 164라인에 제이쿼리객체가 선언되어있다. 

	jQuery = function( selector, context ) {

		// The jQuery object is actually just the init constructor 'enhanced'
		// Need init if jQuery is called (just allow error to be thrown if not included)
		return new jQuery.fn.init( selector, context );
	};
객체생성자에 멤버(속성 메서드를 추가할때) 
$.fn= jQuery.fn = jQuery.prototype
 jQuery는 $기호로 사용하기 때문에 $.fn로 사용가능 
<script>
      var person={ //js object 
        name:"hong",
        age:20,        
    };
    var b=$("body"); //jquery object 
    alert(b.jquery); //3.6.0
    alert(person.jquery);  //undefined
    alert($.fn.jquery); //3.6.0 
    //제이쿼리 버전을 객체생성 없이도 할 수 있다. 
    
</script>

'WEB > JQuery' 카테고리의 다른 글

[JQuery] on() , one(), off()  (0) 2022.06.14
[JQuery] wrap()/upwrap()  (0) 2022.06.14
[JQuery] jQuery noConflict() -$ 기호 충돌문제 해결  (0) 2022.06.14
[JQuery] Traversing  (0) 2022.06.13
[JQuery] event.preventDefault() - 링크이동안함  (0) 2022.06.13
Comments