课后作业(五)String对象的常用属性和方法

Code:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  5. <title>无标题文档</title>  
  6. </head>  
  7.   
  8. <body>  
  9. <p>  
  10. <input type="text" id="da" />  
  11. <input type="button" value="换成大写" οnclick="da()" />  
  12. <input type="text" id="da1" />  
  13.   
  14.   
  15. <p>  
  16. <input type="text" id="xiao" />  
  17. <input type="button" value="换成小写" οnclick="xiao()" />  
  18. <input type="text" id="xiao1" />  
  19.   
  20.   
  21. <p>  
  22. <input type="text" id="huoqu1" />  
  23. <input type="text" id="huoqu2"  size="5"/>确认截取长度  
  24. <input type="button" value="获取字符串" οnclick="jiequ()"/>  
  25. <input type="text" id="huoqu3" />  
  26.   
  27.    
  28.   
  29.   
  30. <p>  
  31. <input type="text" id="chazhao1" />  
  32. <input type="button" value="查找@字符" οnclick="cha()"/>  
  33. <input type="text" id="chaozhao2" />  
  34. </body>  
  35. <script language="javascript">  
  36.  function da()  
  37.   {  
  38.    var a = document.getElementById("da").value;  
  39.    document.getElementById("da1").value = a.toUpperCase();  
  40.     
  41.   }  
  42.   
  43.  function xiao()  
  44.   {  
  45.    var a = document.getElementById("xiao").value;  
  46.    document.getElementById("xiao1").value = a.toLowerCase();  
  47.     
  48.   }  
  49.   
  50.   
  51.  function jiequ()  
  52.   {  
  53.    var a=new String (document.getElementById("huoqu1").value);  
  54.  document.getElementById("huoqu3").value=a.substring(0,parseInt(document.getElementById("huoqu2").value));  
  55.     
  56.     
  57.   }  
  58.     
  59.   function cha()  
  60.   {  
  61.    var a=new String (document.getElementById("chazhao1").value);  
  62.  document.getElementById("chaozhao2").value=a.indexOf("@",0)+1;  
  63.   }  
  64.   
  65. </script>  
  66. </html>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值