报错:Uncaught TypeError: LightBox is not a constructor
大家帮我看看代码,代码跟视频上的一样啊,为什么不能alert 1出来。
报错:Uncaught TypeError: LightBox is not a constructor
js:
;(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");
}
};
window["LightBox"] = LightBox;
})(jQuery);
html页面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/jquery-2.2.1.min.js"></script>
<script src="js/LightBox.js"></script>
</head>
<body>
<script>
$(function(){
var LightBox = new LightBox();
})
</script>
</body>
</html>