欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

JQ核心骨架

发布时间:2025/5/22 编程问答 39 豆豆
生活随笔 收集整理的这篇文章主要介绍了 JQ核心骨架 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
(function(){var jQuery = function(id){return new _jquery(id);};var _jquery = function(id){//此处各种选择分支神马的都忽略~this[0] = document.getElementById(id);this.length = 1;};jQuery.fn = jQuery.prototype = {constructor: jQuery,addClass: function(className){this[0].className += ' ' + className;}};_jquery.prototype = jQuery.fn;window.$ = window.jQuery = jQuery;})(); (function( window, undefined ) { varjQuery = function( selector, context ) {// The jQuery object is actually just the init constructor 'enhanced'return new jQuery.fn.init( selector, context, rootjQuery );};//各种原型属性jQuery.fn = jQuery.prototype = {constructor: jQuery,init: function( selector, context, rootjQuery ) {//... },...};jQuery.fn.init.prototype = jQuery.fn;//extend方法,用来扩展jQuery,或jQuery.fnjQuery.extend = jQuery.fn.extend = function() {//... };jQuery.fn.extend({addClass: function( value ) {//...return this; //返回this,链式调用的秘密 }});window.jQuery = window.$ = jQuery;})( window );

 

转载于:https://www.cnblogs.com/haohaoday/p/3336866.html

总结

以上是生活随笔为你收集整理的JQ核心骨架的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。