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

 

你可能感兴趣的:(js对象)