JSLite - Plug-in writing
If you have any questions, you are welcome to communicate in these places, and you are welcome to join the JSLite.io organization team for joint development!
$.extend
Expand the properties of the target object through the source object, extending the
JSLite
element set to provide new methods (usually used to make Plugins)
$.extend({ min: function(a, b) { return a < b ? a : b; }, max: function(a, b) { return a > b ? a : b; } }); $.min(2,3); //⇒ 2 $.max(4,5); //⇒ 5 // 在$上扩展了几个方法 //调用方法 $.min(2,3); //⇒ 2 //调用方法 $.max(4,5); //⇒ 5
$.fn.extend
Extends the
JSLite
element set to provide new methods (commonly used to make plugins).
$.fn.extend({ //增加两个插件方法。 check: function() { return this.each(function() { this.checked = true; }); }, uncheck: function() { return this.each(function() { this.checked = false; }); } }); $("input[type=checkbox]").check(); //选中 $("input[type=radio]").uncheck(); //取消选中
$.error
The
error
event occurs when an element encounters an error (not loaded correctly).
$.error("2222") //⇒ 输出错误 Uncaught 2222