求大腿:不知道是不是jQ版本不对,我用的2.1.4,renderDOM()没有运行,alert都不得行

来源:3-1 DOM结构渲染

勇哥萌萌哒

2016-05-30 22:58

;(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);


写回答 关注

1回答

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

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

JS插件开发之LightBox图片画廊(上)

图片画廊插件开发综合演练,快来加入我们的课程吧

27071 学习 · 81 问题

查看课程

相似问题