好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

javascript小记

javascript小记

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"));

查看更多关于javascript小记的详细内容...

  阅读:46次