; (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. AutoHotkey 使用笔记

    注意事项 为了支持中文需安装 AutoHotkey_L Notepad2对ahk代码高亮和折叠支持良好,SciTE则能够提供输入提示 绿色版*.ahk关联AutoHotkey.exe就能双击运行 Au ...

  2. qt qml scrollbar 移动APP风格的滚动轴

    依附于Flickable组件的滚动轴    自动放置在恰当位置    拖动时显示,不动时消失Lisence: MIT 请保留此声明Author: surfsky.cnblogs.com 2014-12 ...

  3. 设置Beyond Compare 为 Git 默认的比较工具

    对于Beyond Compare4,Git版本号在2.2.0之后的,请在Git中依次输入以下命令: git config --global diff.tool bc3 git config --glo ...

  4. Dell DRAC的重启方法

    SSH 22连接后:racadm racreset

  5. <Interview Problem>二叉树根到叶节点求和值匹配

    题目大意:一颗二叉树,每个节点都有一个Value, 判断根节点到叶节点的路径求和值是否等于某个数Sum. 比如说如下这样一颗二叉树,76是45,21,10这条路径的求和值,77就没有满足条件的路径. ...

  6. (更新)Java + 腾讯企业邮箱 + javamail + SSL 发送邮件

    咳咳~最头疼的就是莫名其妙的错误. 本来今年6月份运行通过的代码,过俩月就报错了. javax.mail.MessagingException: Could not connect to SMTP h ...

  7. ajax动态添加的li不能绑定click事件

    单纯的给li标签添加click事件,是不会执行的. 经过试验 <ul id="searchedUser"><li>搜索结果</li></u ...

  8. 利用JavaScript来实现省份—市县的二级联动

    所谓省-市二级联动是指当选择省份下拉选择框时,市县的下拉框会根据选择的省市而有相应的市县加载出来,如下图所示选择"上海市",城市的下拉选择框只会出现上海的市县: 这种二级联动非常常 ...

  9. MPI Maelstrom - POJ1502最短路

    Time Limit: 1000MS Memory Limit: 10000K Description BIT has recently taken delivery of their new sup ...

  10. GDUFE-OJ 1361校庆抽奖 翻转

    Problem Description: 在舞台中央有一个开奖盒,开奖盒有一个按钮,和一个显示屏,每轮抽奖是过程是这样的. 主持人请K个幸运观众上台,编号为1~K,围着开奖盒. 首先开奖盒上随机显示一 ...