ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 자바 스크립트 함수
    언어/HTML&CSS&JAVA Script 2020. 4. 27. 17:39
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8">
    <script>
        function add(){
            var sum=1;
            return sum;
        }
        function add(x){
            var sum=x+1;
            return sum;
        }
        function add(x,y){
            var sum =x+y;
            return sum;
        }
        function add(x,y,z){
            var sum= x+y+z;
            return sum;
        }
     
        var r0=add();
        var r1=add(1);
        var r2=add(2,3);
        var r3=add(4,5,6);
        var r4=add(7,8,9,10);
     
        document.write("함수호출인자없음:"+r0+"<p/>");
        document.write("함수호출인자부족:"+r1+"<p/>");
        document.write("함수호출인자부족:"+r2+"<p/>");
        document.write("정상적인함수호출:"+r3+"<p/>");
        document.write("7,8,9만 인자값으로 적용:"+r4+"<p/>")
     
    </script>
    </head>
     
    <body>
    </body>
    </html>
    ///////////////////////////////////
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8">
    <script type="text/javascript">
        var text1="함수선언전 호출";
        var text2="함수선언전 호출";
        printMsg(text1);
        function printMsg(msg){
            document.write("함수호출 메시지:"+msg+"<br>");
        }
        printMsg(text2);
    </script>
    </head>
     
    <body>
     
    </body>
    </html>
    ///////////////////////////////////
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8">
        <script type="text/javascript">
            function printMsg(name,age) {
                document.write("학생이름:<b>"+name+"</b><br>");
                document.write("학생나이:<b>"+age+"</b><br>");
            }
        </script>
    </head>
    <body>
        <button type="button" onclick="printMsg('홍길동',21)">학생정보</button>
    </body>
    </html>
     
     
    http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
    http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

     

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8">
        <script type="text/javascript">
            var i=0;
            document.write(i);
            document.write("<br>");
            var name ="홍길동";
            document.write(name);
            document.write("<br>");
            var a=1;
            var b=2;
            var c=a+b;
            document.write(c);
     
        </script>
        <script type="text/javascript">
            function msg(){
                window.alert("msg test");
            }
            //msg();
            function add(a ,b){
                c=+b;
                alert(c);
            }
     
            function test(){
                document.getElementById("result").value="1234";
                document.getElementById("result").style.color="red";
            }
            document.write("<br>");
        
        </script>
     
    </head>
    <body>
     
        <button type="button" onclick="msg();"> click me </button>
        <button type="button" onclick="add(1,2);"> click me2 </button>
        <br>
        <button type="button" onclick="test();"> click me3 </button>
        <input type="text" name="result" id="result">
     
    </body>
    </html>
    ////////////////////////////////////////
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <script type="text/javascript">
            function add(){
                var num1=document.getElementById('num1').value;
                var num2=document.getElementById('num2').value;
                //alert(typeof num1);
                var result=Number(num1)+Number(num2);
                document.getElementById('num3').value=result;
                
            }
        </script>
    </head>
    <body>
        <input type="text" name="num1" id ="num1" size="3"> +
        <input type="text" name="num2" id ="num2" size="3"> =
        <input type="text" name="num3" id ="num3" size="3" >
        <br>
        <input type="button" value="add" onclick="add();">
    </body>
    </html>
     
    http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
    http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

     

    '언어 > HTML&CSS&JAVA Script' 카테고리의 다른 글

    jQuery 회원가입  (0) 2020.05.15
    자바스크립트 로그인 화면 만들기  (0) 2020.04.27
    position  (0) 2020.04.27
    CSS우선순위  (0) 2020.04.25
    CSS가상클래스 선택자  (0) 2020.04.25
Designed by Tistory.