(function($) {
    // 插件的定义
    // var opts;
    $.fn.modelwindow = function(options) {
        debug(this);
        // build main options before element iteration
        opts = $.extend({}, $.fn.modelwindow.defaults, options);

        $("#contentdiv").css({ display: "none" });
        // iterate and reformat each matched element     
        this.each(function() {

            //  var markup = $this.html();
            // call our format function

            $(this).click(function() {
                $("#contentdiv").html(showdiv($(this).attr("href")), opts);
                $("#contentdiv").fadeIn(700)
                return false;
            });

        });
    };
    // 私有函数:debugging     
    function debug($obj) {
        if (window.console && window.console.log)
            window.console.log('modelwindow selection count: ' + $obj.size());
    };
    // 定义暴露format函数     
    $.fn.modelwindow.format = function(txt) {
        return '<strong>' + txt + '</strong>';
    };
    // 定义弹出层函数
    showdiv = function(url, opts) {
        return '<div >
})(jQuery);     
 
 
调用方法
$(document).ready(function() {
     $("a").modelwindow({
      onclosed: function(data) { $("#cb").val(data); },
      callbackcontentid: "#Text4"

    })
})

 

相关文章: