대소문자변환 > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

대소문자변환 정보

JavaScript 대소문자변환

본문

<script>
str="";
test=prompt('영문자를 입력하세요 - 대소문자 혼용가능','AbCdEf');
for(i=0;i<test.length;i++){
if(test.charCodeAt(i)<90&&test.charCodeAt(i)>65){ //대문자의경우
str+=i+":"+test.charAt(i)+":"+test.charAt(i).toLowerCase()+"<br>"; //소문자로
} else {
str+=i+":"+test.charAt(i)+":"+test.charAt(i).toUpperCase()+"<br>"; //소문자는 대문자로
}
}
document.write(str);
</script>
추천
0
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로