; (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. response.write();改变页面布局的原因及解法

    Response.Write ,在ASP.NET 中不要随便使用 Response.Write,其原因是它会打乱 ASP.NET 的输出流顺序,在aspx.cs 中使用 Response.Write ...

  2. viewport设置

    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable ...

  3. Linux_用户级_常用命令(5):rm

    Linux常用命令第5集包含命令:rm 开篇语:懒是人类进步的源动力 本文原创,专为光荣之路公众号所有,欢迎转发,但转发请务必写出处! 一.命令简介 删除一个目录中的一个或多个文件或目录,如果没有使用 ...

  4. js 自带的 map() 方法

    1. 方法概述 map() 方法返回一个由原数组中的每个元素调用一个指定方法后的返回值组成的新数组. 2. 例子 2.1 在字符串中使用map 在一个 String  上使用 map 方法获取字符串中 ...

  5. windows+caffe(七)——ComputeImageMean.bat

    1.首先我们使用lmdb数据格式(怎样得到lmdb数据格式,看我的另一篇)求得均值: 新建ComputeImageMean.bat,里面输入: D:/deeptools/caffe-windows-m ...

  6. 8. apache服务实验笔记

    Apache服务器 一 简介 1 www:world  wide  web 万维网 http 协议: 超文本传输协议 HTML语言: 超文本标识语言 2 URL:统一资源定位 协议+域名:端口+网页文 ...

  7. json字符串转java对象数组

    需要引入json-lib-2.2-jdk15.jar和ezmorph-1.0.6.jar包 String itemStar = request.getParameter("itemStar& ...

  8. laravel框架总结(八) -- ORM模型

    ORM模型简介 1>什么是ORM? ORM,即 Object-Relational Mapping(对象关系映射),它的作用是在关系型数据库和业务实体对象之间作一个映射,这样,我们在操作具体的 ...

  9. Netsuite > Hierarchy of transactions in Inventory cost calculation

    First in day worksheets + Purchase Transactions (Receipts, Bills, Adjustments, Assembly Builds) + Tr ...

  10. POSTMAN as debugger for integration APPs

    Chrome Menu: Window > Extensions > Postman - REST Client 0.8.4.10 起个标题,有空总结一下一个经验,关于Netsuite i ...