// 插件的定义
来源:互联网 发布:淘宝天猫积分怎么获得 编辑:程序博客网 时间:2024/06/04 18:33
实时监听文本框变化:
$('#username').bind('input propertychange', function() {
$('#username').bind('input propertychange', function() {
$('#content').html($(this).val().length + ' characters');
});
// 创建一个闭包
(function($) {
// 插件的定义
//采用全局对象window来暴露接口
window.tool=window.tool || {}
window.tool.hilight=function(){
//逻辑处理代码
}
//采用jquery暴露 hilight接口
//采用全局对象window来暴露接口
window.tool=window.tool || {}
window.tool.hilight=function(){
//逻辑处理代码
}
//采用jquery暴露 hilight接口
$.fn.hilight = function(options) {
debug(this);
// build main options before element iteration
var opts = $.extend({}, $.fn.hilight.defaults, options);
// iterate and reformat each matched element
return this.each(function() {
$this = $(this);
// build element specific options
var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
// update element styles
$this.css({
backgroundColor: o.background,
color: o.foreground
});
var markup = $this.html();
// call our format function
markup = $.fn.hilight.format(markup);
$this.html(markup);
});
};
// 私有函数:debugging
function debug($obj) {
if (window.console && window.console.log)
window.console.log('hilight selection count: ' + $obj.size());
};
// 定义暴露format函数
$.fn.hilight.format = function(txt) {
return '<strong>' + txt + '</strong>';
};
// 插件的defaults
$.fn.hilight.defaults = {
foreground: 'red',
background: 'yellow'
};
// 闭包结束
})(jQuery);
0 0
- 软件插件的定义
- // 插件的定义
- jQuery插件定义的基本原则
- jQuery定义插件的方法
- 如何使用MITK定义的插件
- RPGMaker MV 插件基础02:插件的参数定义
- 学会定义Jquery插件
- 定义JQuery插件
- 定义JQuery插件
- 定义JQuery插件
- 插件规范定义
- jquery插件定义
- JQuery插件定义
- jquery定义插件
- Qt插件定义
- solr中如何定义自己的解析器插件(QParserPlugin)
- rcp(插件开发) 如何查找自己定义的扩展点
- Maven小技巧 - eclipse.m2e的插件运行定义
- 用于设置文本过长 撑破css布局:
- 第03周:项目三:家用电子表的制作
- 扯点关于tnsping的一点事
- 关于《算法概论》的思维导图
- Bouncy Castle 算法配置
- // 插件的定义
- 《java多线程设计模式 第五章Producer Consumer》
- combinations
- C has memset(), the Berkeley UNIX C library has bzero()
- 有效获取scrollWidth clientWidth方法:
- django POST获取字典
- 数据可视化-Python之Matplotlib
- hdu 1874 (spfa)
- window编程控件的基本使用