Posted on 2012-08-12 12:49
mr.zhao 阅读(274)
评论(0) 编辑 收藏
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <title>MyHtml.html</title>
5
6 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
7 <meta http-equiv="description" content="this is my page">
8 <meta http-equiv="content-type" content="text/html; charset=gbk">
9 <script type="text/javascript">
10 function zhuanHuan(){
11 var dc=document.getElementById("zimu").value;
12 var temp;
13 var temp1 = dc.charAt(0).toUpperCase();
14 for(var i=1;i<dc.length;i++){
15 temp=dc.charAt(i);
16 if(temp==" "&&i<dc.length-1){
17 temp=" "+dc.charAt(i+1).toUpperCase();
18 temp1=temp1+temp;
19 i++;
20 }
21 else{
22 temp1 = temp1 + temp;
23 }
24 }
25 document.getElementById("zimuhou").value=temp1;
26 }
27 </script>
28 </head>
29
30 <body>
31 <div>
32 <span>请输入单词:</span>
33 <input type="text" id="zimu"/>
34 <input type="button" value="转换首字母大写" onclick="zhuanHuan()"/>
35 <input type="text" id="zimuhou" />
36 </div>
37 </body>
38 </html>