티스토리 뷰

 

 

# input type 종류

--이거 그대로 직접 실행 해서 눈으로 보셈--

 

<html>
<head>
<style type="text.css">
</style>
<script>

</script>
</head>
<body>

 <input type="text"><br/>


 <input type="password"><br/>


 <textarea></textarea><br/>


 <input type="checkbox"><br/>


 <input type="radio"><br/>


 <input type="reset"><br/>


 <select>
 <option>aa</option>
 <option>bb</option>
 <option>cc</option>
 </select><br/>


 <input type="file"><br/>


</body>
</html>  

 

 

 

# 자바스크립트의 자료형 

 

<html>

<body>

 <script>

 var a=100;

 var b="abc";

 var c=new Date();

 var d=function(){ return 100; };

 var e=true;

 

 document.write((typeof a)+"<br/>");    //number

 document.write((typeof b)+"<br/>");    //string

 document.write((typeof c)+"<br/>");    //object

 document.write((typeof d)+"<br/>");    //function

 document.write((typeof e)+"<br/>");    //boolean

 document.write((typeof f)+"<br/>");     //undefin

 </script>

</body>

</html>

 

 

 

# 주석문

 

<html>
<head>
<style type="text/css">
 /* body { color:red; } */    ---> css 주석문
</style>
<script>
 function a(){
 document.write("abc");
 }
</script>
</head>
<body>
 <script>
 /* a(); */                          --> 스크립트안 java구문 주석문
 </script>
 aaa<br/>
 <!-- bbb<br/> -->              -->자바스크립트 주석문
 ccc<br/>
</body>
</html>

 

 

 

 

# 배열

 

[SY]  

var array=[100,200,300];

 

 

<html>
<head>
<script>
function a(){
 alert(111);
 var array=[100,200,300];
 return array;
}
</script>
</head>
<body>
<script>
var array2=a();      --> 배열 return 으로 받아서 alert를 한번만 출력되게 효율적으로 사용.
document.write(array2[0]); // 100
document.write("<br/>");
document.write(array2[1]); // 200
document.write("<br/>");
document.write(array2[2]); // 300
</script>
</body>
</html>

 

 

#내장함수

해보면 안다.

 

 1) confirm 내장함수

 

<html>
<head>
<style type="text/css">
 td { border:1px solid navy; }
</style>
</head>
<body>
<table>
<script>
  var sex=confirm("당신 여자야?");
  if(sex){
  document.write("<font color=red>여자</font>");}
  else{document.write("<font color=blue>남자</font>"); }
 </script>
</table>
</body>
</html>

 

2) prompt 내장함수

 

<html>
<body>
 <script>
 var a=prompt("첫번째숫자입력",100);
 var n1=parseInt(a);
 var n2=parseInt(prompt("두번째숫자입력",200));
 document.write(n1+n2);
 </script>
</body>
</html>

 

3) alert 내장함수

<html>
 <body>
 <script>
 function a(){ alert(100); }
 function b(){ alert(200); }

 function test(n){
 n();
 }

 test(a);
 test(b);
 </script>
 </body>
</html>

댓글