me.init函数如何知道其他函数的init [英] how would me.init function know the init of other functions
问题描述
我有这个index.html文件:
i have this index.html file :
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="content/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="content/main.css">
<!-- jQuery library -->
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>-->
<script src="scripts/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="scripts/bootstrap.min.js"></script>
<script src="App/data.js"></script>
<script src="App/main.js"></script><!---calling all the .int files -->
<style type="text/css">
#main_light_layover {
width:20px;
height:20px;
padding:20 20;
background-color:yellow;
}
#main_deep_layover {
width:20px;
height:20px;
padding:20 20;
background-color:green;
}
#main_regular_layover {
width:20px;
height:20px;
padding:20 20;
background-color:purple;
}
</style>
</head>
<body>
<div id="main_right_line_one"> one </div>
<div id="main_right_line_two"> two </div>
<div id="main_right_line_three">three </div>
<div id="main_light_layover"> </div>
<div id="main_deep_layover"> </div>
<div id="main_regular_layover"> </div>
</body>
</html>
然后我有这个main.js文件,其中我应该包括所有.init()功能:
then i have this main.js file where i should include all the .init() functions:
var main=(new function(){
var me=this;
me.init=function(){
divEditScreen.init();
}
}());
$(document).ready(function () {
main.init();
});
divEditScreen是一个变量与目录:App - >用户---> Edit.js // main.js目录是App - > main.js。
在这个文件里面(App - > Users ---> Edit.js)
"divEditScreen" is a variable with directory : App --> Users --->Edit.js // the main.js directory is App -->main.js .
inside this file (App --> Users --->Edit.js)
var divEditScreen = (new function () {
var me = this;
me.init = function () {
$("#main_right_line_one").click(function () {
me.fade();
});
}
me.fade = function () {
$('#main_regular_layover, #main_deep_layover').fadeOut('slow', function () {
$('#main_light_layover').fadeIn('slow');
});
}
}());
< br $>
为什么我得到一个错误,没有定义divEditScreen?
why do i get an error that divEditScreen is not defined ?
推荐答案
(document).ready(function(){
main.init();
});
(document).ready(function () { main.init(); });
divEditScreen是一个带目录的变量:App - >用户---> Edit.js // main.js目录是App - > main.js。
在这个文件里面(App - > Users ---> Edit.js)
"divEditScreen" is a variable with directory : App --> Users --->Edit.js // the main.js directory is App -->main.js .
inside this file (App --> Users --->Edit.js)
var divEditScreen = (new function () {
var me = this;
me.init = function () {
( #main_right_line_one)。click(function(){
me.fade();
} );
}
me.fade = function(){
("#main_right_line_one").click(function () { me.fade(); }); } me.fade = function () {
(' #main_regular_layover,#main_deep_layover')。fadeOut('' slow',function(){
('#main_regular_layover, #main_deep_layover').fadeOut('slow', function () {
这篇关于me.init函数如何知道其他函数的init的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!