; (function ($, window, document, undefined) {
"use strict"; var defaults = {
name: "xiaoxiao",
age: 18
}; function ShowPepleInfo($ele,options,callback) {
this.$ele = $ele;
this.options = options = $.extend(defaults, options || {});
this.callback = callback || {};//若为undefined则新建callback对象
this.init();
} ShowPepleInfo.prototype = {
constructor: ShowPepleInfo, init: function () {
this.renderHtml();
this.bindEvent();
}, renderHtml: function () {
var options = this.options;
var html = [];
html.push('<div class="info">');
html.push('<p>姓名:' + options.name + '</p>');
html.push('<p>年龄:' + options.age + '</p>');
html.push('</div>'); this.$ele.html(html.join(""));
}, bindEvent: function () {
var that = this;
that.$ele.delegate("p", "click", function () {//直接把事件绑定在父元素$ele
alert($(this).html()); if (typeof that.callback == 'function') {
that.callback($(this).html());//执行回调函数
}
}); }, //others...
} $.fn.showPeopleInfo = function(options,callback){
options = $.extend(defaults, options || {});
return new ShowPepleInfo($(this), options, callback);
} })(jQuery) //使用
$("#main").showPeopleInfo({ name: "dada", age: 20 }, function (e) { alert(e); });
//不用立即执行函数包括
var show = new ShowPepleInfo($("#main"), { name: "dada", age: 20 }, function (e) { alert(e); });
alert(show.options.name);

jQurey Plugin的更多相关文章

  1. 【前端】jQurey Plugin

    ; (function ($, window, document, undefined) { "use strict"; var defaults = { name: " ...

  2. Jenkins 安装的HTML Publisher Plugin 插件无法展示ant生成的JunitReport报告

    最近在做基于jenkins ant  junit 的测试持续集成,单独ant junit生成的junitreport报告打开正常,使用Jenkins的HTML Publisher Plugin 插件无 ...

  3. [转]NopCommerce How to add a menu item into the administration area from a plugin

    本文转自:http://docs.nopcommerce.com/display/nc/How+to+code+my+own+shipping+rate+computation+method Go t ...

  4. MySQL: Table 'mysql.plugin' doesn't exist的解决

    安装解压版MySQL以后,不能启动,日志里面出现了这个错误: MySQL: Table 'mysql.plugin' doesn't exist 这是因为mysql服务启动时候找不到内置数据库&quo ...

  5. JQuery plugin ---- simplePagination.js API

    CSS Themes "light-theme" "dark-theme" "compact-theme" How To Use Step ...

  6. 学习Maven之Maven Clean Plugin

    1.maven-clean-plugin是个什么鬼? maven-clean-plugin这个插件用maven的人都不陌生.我们在执行命令mvn clean时调用的就是这个插件. 这个插件的主要作用就 ...

  7. MySQL 从 5.5 升级到 5.6,启动时报错 [ERROR] Plugin 'InnoDB' init function returned error

    MySQL 从 5.5 升级到 5.6,启动时报错: [ERROR] Plugin 'InnoDB' init function returned error. [ERROR] Plugin 'Inn ...

  8. No plugin found for prefix 'mybatis-generator' in the current project

    http://blog.csdn.net/you23hai45/article/details/50792430 1.错误描述 F:\workspaces\Mybatis>mvn mybatis ...

  9. 创建Unity3D的MacOS Plugin的正确姿势

    http://www.tedlindstrom.se/how-to-link-dylibs-into-unity3d/ I was roaming around the net looking for ...

随机推荐

  1. String 与StringBuilder有什么区别

    C# String 对象是不可改变的.每次使用 System.String 类中的方法之一时,都要在内存中创建一个新的字符串对象,这就需要为该新对象分配新的空间.在需要对字符串执行重复修改的情况下,与 ...

  2. HAL驱动库学习-ADC

    如何使用ADC驱动库 1  实现如下两个函数     a: HAL_ADC_MspInit()使能ADC时钟,设置时钟源, 使能ADC Pin,设置为输入模式,可选 DMA,中断     b:HAL_ ...

  3. 自动刷新页面为了session不过期

    为了保证在打开页面期间session不过期,估做了一个隐藏Iframe每隔若干秒来刷新一下页面,在隐藏页面给session赋值. <script type="text/javascri ...

  4. [SQL入门级] 上篇被移出园子首页,那这篇咱就'薄利多销'

    这个系列的博文知识回顾sql知识作的记录,温故而知新.上一篇内容达不到知识分享的层级被移出园子首页,对不住各位看官,内容简单了些.下面咱就记录多一些的基础知识,薄利多销: 控制用户权限 • 创建用户 ...

  5. 跳转 linQ

    <a href="../Book/BookDetail?book_id=@book.book_id">@book.book_name</a> query + ...

  6. 一次爬虫实践学习(C#)

    我们经常浏览网页,有时候看到一些精美的图片,想下载下来保存,但是太多,如果一张一张的下载,那太费时了:如果你喜欢看书,看小说,那么浏览小说网站是常有的事,但是有时候我们不能联网,比如农村老家,如果还想 ...

  7. uboot命令

    uboot是怎么启动kernel的呢? 先熟悉一下uboot的命令吧. 首先是md, 查看内存. OpenJTAG> md 000000000: ea000014 e59ff014 e59ff0 ...

  8. HTTP/TCP

    转:http://blog.csdn.net/sundacheng1989/article/details/28239711 http://blog.csdn.net/sundacheng1989/a ...

  9. DNS

  10. 利用反射+AOP,封装Basehandler

    AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP是OOP的延续,是软件开发中的一个热点, ...