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>