复制代码 代码如下: <script type="text/javascript"> var test = { numA: 10, objB: {}, arrC: [], init: function(){ alert(this.numA); }, sayHi: function(name){ alert("hello " + name); }, sayHelloWorld: function(){ this.sayHi("world"); }, get: function(){ var self = this; this.objB.alertNumA = function(){ alert(self.numA); } } }; var TestFunc = function(){ alert("i'm testFunc"); }; TestFunc.prototype = { extFunc: function(){ alert("this extend function's numB is " + this.numB); }, numB: 10 }; test.init(); test.sayHi("qingming"); test.sayHelloWorld(); test.get(); test.objB.alertNumA(); var testFunc = new TestFunc(); testFunc.extFunc(); </script>
推荐阅读
jQuery.Validate 使用笔记(jQuery Validation范例 )
验证操作类formValidatorClass.js 复制代码 代码如下: /** * @author ming */ $(document).ready(function(){ /**//* 设置默认属性 */ $.validator.setDefaults({ submitHandler: function(form) { form.submit();>>>详细阅读
本文标题:javascript面向对象编程(一) 实例代码
地址:http://www.17bianji.com/kaifa2/JS/26146.html
1/2 1