<html>
<head>
<title>
test
</title>
</head>
<body>
<input type="text" name="mytxt" value=" 12345678 " />
<input type="button" name="cmd1" onclick="mytxt2.value=mytxt.value.trim()" value="去两边的空格"/>
<input type="text" name="mytxt2"/>
<input type="button" name="cmd1" onclick="mytxt3.value=mytxt.value.ltrim()" value="去左边的空格"/>
<input type="text" name="mytxt3"/>
<input type="button" name="cmd1" onclick="mytxt4.value=mytxt.value.rtrim()" value="去右边的空格"/>
<input type="text" name="mytxt4"/>
<script language="javascript">
String.prototype.trim=function(){
return this.replace(/(^/s*)|(/s*$)/g, "");
}
String.prototype.ltrim=function(){
return this.replace(/(^/s*)/g,"");
}
String.prototype.rtrim=function(){
return this.replace(/(/s*$)/g,"");
}
</script>
</body>
</html>
<!-- button 变灰色 -->
<html>
<head>
<title>code by meixx</title>
</head>
<body>
<input type="button" onclick="this.disabled=true" value="Click Me">
</body>
</html>