一、大方法中包含小方法:
- <script type="text/javascript">
- function animal(){
- this.dog = function(){
- if(document.getElementById("username").value == ""){
- alert("hi,I'm dog.");
- }
- }
- this.cat = function(){
- if(document.getElementById("password").value == ""){
- alert("hi,I'm cat.");
- }
- }
- }
- new register().dog(); //调用方法
- </script>
二、定义域:
var baseControl = {
add : function() {
alert("I'm adding");
},
del : function() {
alert("I'm deleting");
},
edit : function() {
alert("I'm editing");
},
query : function() {
alert("I'm quering");
},
view : function(custid) {
alert("I'm viewing");
},
export2Xls : function() {
alert("I'm exporting");
}
};