求大腿:不知道是不是jQ版本不对,我用的2.1.4,renderDOM()没有运行,alert都不得行
;(function($){
var LightBox = function(){
var self = this;
//创建遮罩和弹出框
this.popupMask = $("<div id='G-lightbox-mask'></div>")
this.popupWin = $("<div id='G-lightbox-popup'></div>")
//保存body
this.bodyNode = $(document.body);
//渲染剩余的DOM插入到body;
this.renderDOM();
};
LightBox.prototype = {
renderDOM:function(){
alert("1");
var strDom = "<div class='lightbox-pic-view'>"+
"<span class='lightbox-btn lightbox-prev-btn'></span>"+
"<img class='lightbox-img' src='img/1.jpg' width='100%'>"+
"<span class='lightbox-btn lightbox-next-btn'></span>"+
"</div>"+
"<div class='lightbox-pic-caption'>"+
"<div class='lightbox-caption-area'>"+
"<p class='lightbox-pic-desc'></p>"+
"<span class='lightbox-of-index'>当前索引:1 of 4</span>"+
"</div>"+
"<span class='lightbox-btn-close'></span>"+
"</div>";
//插入到this.popupWin;
this.popupWin.html(strDom);
//把遮罩和弹出框插入到body;
this.bodyNode.append(this.popupMask,this.popupWin);
}
};
window["LightBox"] = LightBox;
})(jQuery);