¸üÐÂʱ¼ä:2021Äê06ÔÂ10ÈÕ13ʱ48·Ö À´Ô´:ºÚÂí³ÌÐòÔ± ä¯ÀÀ´ÎÊý:
£¨1£©¿¼²ìÄ¿±ê
1£©¿¼²ìÊÇ·ñ×Ô¼º±àд¹ýÍØÕ¹²å¼þ
2£©ÊÇ·ñÖªµÀΪjQueryÀ©Õ¹²å¼þµÄ·½·¨
£¨2£©ÌâÄ¿·ÖÎö
1£©Í¨¹ý$.extend()À´À©Õ¹jQuery
2£©Í¨¹ý$.fn ÏòjQueryÌí¼ÓÐµķ½·¨
´úÂë
// 1. ͨ¹ý$.extend()À´À©Õ¹jQuery
// Óï·¨£º $.extend({})
// ȱµã£ºÕâÖÖ·½Ê½ÎÞ·¨ÀûÓÃjQueryÇ¿´óµÄÑ¡ÔñÆ÷´øÀ´µÄ±ãÀû£¬
$.extend({ log: function(msg) { var now = new Date(),
y = now.getFullYear(),
m = now.getMonth() + 1,
d = now.getDate(),
h = now.getHours(),
min = now.getMinutes(),
s = now.getSeconds(),
time = y + '/' + m + '/' + d + ' ' + h + ':' + min + ':' + s; console.log(time + '--' + msg);
}
})
$.log('initializing'); //µ÷ÓÃ
// 2. ͨ¹ý$.fn ÏòjQueryÌí¼ÓÐµķ½·¨
/*
Óï·¨
$.fn.pluginName = function() {
//your code goes here
}
*/
// ³£Óõķ½Ê½
$.fn.changeColor = function() { //ÔÚÕâÀïÃæ,thisÖ¸µÄÊÇÓÃjQueryÑ¡ÖеÄÔªËØ
this.css('color', 'red');
}
$(function() {
$('a').changeColor();
})
</script>
£¨3£©Ó¦Óó¡¾°
ʲôÊÇjQuery£¿jQueryÓÐÄÄЩÓÅÊÆ£¿
jQueryÈçºÎʹÓÃcss·½·¨Ð޸ĵ¥¸öÑùʽ£¿
jQuery¿âÖеÄ$()ÊÇʲô?
ÀÖÓãµç¾ºÇ°¶ËÓëÒÆ¶¯¿ª·¢¿ª·¢Åàѵ
±±¾©Ð£Çø