javascript小记

  • 时间:
  • 浏览:
  • 来源:互联网
javascript小记
ContractedBlock.gif ExpandedBlockStart.gif Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn">
<head>
<title></title>
</head>
<body>

<script type="text/javascript">
//<![CDATA[
function classTest(){
    
var name,sex,age;
    
this.setName=function(x){
        name
=x;
    }
    
this.setSex=function(x){
        sex
=x;
    }
    
this.setAge=function(x){
        age
=x;
    }
    
this.getName=function(){
        
return name;
    }
    
this.getSex=function(){
        
return sex;
    }
    
this.getAge=function(){
        
return age;
    }
}

var person=new classTest();
person.setName(
"毛凌志");
person.setSex(
"");
person.setAge(
27);

alert(person.getName()
+"\n"+person.getSex()+"\n"+person.getAge())
//]]>
</script>
</body>
</html>

 

js中的正则

 var re=new RegExp('(^| )'+"te"+'( |$)');
 alert(re.test("abc te"));

 

posted on 2009-03-03 15:26  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2009/03/03/1402269.html

本文链接http://ha.ngui.cc/a/17053.html