javascript类的定义

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    
<title>javascript类的定义</title>
    
<script type="text/javascript">
        
function Go(s){this.Init(s)};//创建类
        Go.prototype={//定义属性与方法
          step:0,
          start:
0,
          kill:{b:
0,w:0},//创建ArrayList
          Rend:function(){
            alert(
'Rend');
          },
          Init:
function(s){
            
this.step=s;
          }
        }
        
function f(){
            
var g = new Go(1);
            g.Rend();
            alert(g.step);
            alert(g.kill[
'b']);
        }
    
</script>
</head>
<body>
    
<input type="button" value="ok" onclick="f();" />
</body>
</html>
posted @ 2009-07-30 15:50  大气象  阅读(384)  评论(2编辑  收藏  举报
http://www.tianqiweiqi.com