点击“转换”按钮后,将字符串“hAPPYimastudentNOw”中的大写字母转换成小写字母,小写字母转换成大写字母并输出。(提示: charCode在65-90之间表示是大写字母,97-122之间为小写字母)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>5</title>
<script>
function test(){
var temp = "hAPPY,i'm a student,NOW"; var temp1 = "";
for(var i=0; i<temp.length; i++){
/* ********FOUND********* */
var ch = temp.substr(i,1);
var as = temp.charCodeAt(i);
if(65<=as&&as<=90){
/* ********FOUND********* */
temp1+=ch.toLowerCase(); }
else if(97<=as&&as<=122){
/* ********FOUND********* */
temp1+=ch.toUpperCase();}
else{
temp1+=ch; } }
document.write("转换之前"+temp+"<br>"+"转换之后"+temp1); }
</script> </head>
<body>
<!-- ********FOUND********* -->
点击转换大小写<input type="button" value="转换" onclick="test()">
</body>
</html>