; (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. [LeeCode]Power of Two

    Given an integer, write a function to determine if it is a power of two. My initial code: class Solu ...

  2. C# 使用BackgroundWorker例子及注意点

    该例子为使用BackgroundWorker在TextBox文本中产生一个10000以内并且能被5整除的数(1秒产生一个) 操作界面可以启动线程,也可以停止线程,界面设计如图: 先贴代码,有注释的地方 ...

  3. logrotate

    logrotate程序是一个日志文件管理工具.用于分割日志文件,删除旧的日志文件,并创建新的日志文件,起到"转储"作用.可以节省磁盘空间. logrotate命令格式:logrot ...

  4. Linq创建带命名空间、前缀、Soap格式的XML

    关于XML,我也是刚接触,关于一般常见的XML,博客园.CSDN上的资料很多,对于不常见的带命名空间.前缀.Soap格式的XML的描述相对来说寥寥无几,上一篇我写到了对相对复杂的XML的读操作,下面说 ...

  5. XML Schema choice 元素

    XSD : <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sch="http://w ...

  6. mybatis,Spring等工具对xml文件正确性的验证

    我们知道mybatis或者spring都是使用xml文件作为配置文件,配置文件的格式都是定义在叫做.dtd或者.xsd文件中的,当工具在解析用户自己定义的xml文件的时候,如何才能知道用户自定义的文件 ...

  7. webstorm--破解

    2016.2.2 版本的破解方式: 安装以后,打开软件会弹出一个对话框:选择"license server" 输入:http://114.215.133.70:41017 2016 ...

  8. php中echo(),print(),print_r()之间的区别

    echo是PHP语句, print和print_r是函数,语句没有返回值,函数可以有返回值(即便没有用)  print只能打印出简单类型变量的值(如int,string)  print_r可以打印出复 ...

  9. 阿里云CentOS6.5搭建服务器JDK+tomcat+MySQL

    阿里云ECS,计划安装jdk:MySQL:tomcat: 一.yum Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的S ...

  10. fnciton

    -----oracle将字段字符分隔作为临时表 select column_value as site_id from table (select fn_split_clob(dashboard_pr ...