js對象封裝

<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<script type="text/javascript" src="jquery-1.8.2.js"></script>
	<script type="text/javascript" src="main.js"></script>
	<script type="text/javascript" src="a.js"></script>
	<script type="text/javascript" src="b.js"></script>
	<script type="text/javascript">
		$(function() {
			
			main.a.hello();
		});
	</script>
</head>
<body>

</body>
</html>


window.main={};


main.a=(function(){
	function hello(){
		alert('a.js');
	}

	return {
		hello: hello
	}
}());

main.b=(function(){
	function hello(){
		alert('b.js');
	}

	return {
		hello: hello
	}
}());

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章