您的位置:首页 > 其它

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

2009-06-30 19:40 781 查看
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">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>无标题文档</title>

</head>

<body>

<p>

<input type="text" id="da" />

<input type="button" value="换成大写" onclick="da()" />

<input type="text" id="da1" />

<p>

<input type="text" id="xiao" />

<input type="button" value="换成小写" onclick="xiao()" />

<input type="text" id="xiao1" />

<p>

<input type="text" id="huoqu1" />

<input type="text" id="huoqu2" size="5"/>确认截取长度

<input type="button" value="获取字符串" onclick="jiequ()"/>

<input type="text" id="huoqu3" />

<p>

<input type="text" id="chazhao1" />

<input type="button" value="查找@字符" onclick="cha()"/>

<input type="text" id="chaozhao2" />

</body>

<script language="javascript">

function da()

{

var a = document.getElementById("da").value;

document.getElementById("da1").value = a.toUpperCase();

}

function xiao()

{

var a = document.getElementById("xiao").value;

document.getElementById("xiao1").value = a.toLowerCase();

}

function jiequ()

{

var a=new String (document.getElementById("huoqu1").value);

document.getElementById("huoqu3").value=a.substring(0,parseInt(document.getElementById("huoqu2").value));

}

function cha()

{

var a=new String (document.getElementById("chazhao1").value);

document.getElementById("chaozhao2").value=a.indexOf("@",0)+1;

}

</script>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: