问答详情
源自:3-1 DOM结构渲染

求大腿:不知道是不是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);


提问者:勇哥萌萌哒 2016-05-30 22:58

个回答

  • 勇哥萌萌哒
    2016-05-30 23:05:28

    原来没有 new LightBox ,已经找到问题了.