본문 바로가기

   
Programming/Javascript

Javascript 함수의 매개변수란

반응형

<!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>

             <title></title>

             <meta name="generator" content="editplus" />

             <meta name="author" content="김종현" />

             <script type="text/javascript">

                    //자바스크립트 함수 선언은 <head>안에서..

                    //1. 단순 함수

                    function Hello() {//함수의 본문(body) - 실행할 코드 집합

                           alert("안녕하세요...김종현님");

                    }

 

                    //2. 인자값 있는 함수

                   function Hello2(name) {//name : 인자(변수) var라는 선언문이 빠진것 뿐이다.

                           //name = "KJH";

                           alert("당신의 이름은" + name + "이 맞습니까?");

                    }

 

                    //Hello2('KJH');

                    //Hello2('이번엔 다른걸 던져줄게');

             </script>

       </head>

 

       <body>

             <!-- Ex04.htm -->

             <div>

                    <input type="button" value="클릭" onclick='Hello();' />

             </div>

 

             <div>

                    <input type="button" value="넌누규" onclick="Hello2('넌누규?');" />

             </div>

 

             <div>

                    <input type="button" value="아무개" onclick="Hello2('다른 사람임');" />

             </div>

 

             <div>

                    <input type="text" onmouseover='Hello();' />

             </div>

            

       </body>

</html>

 

반응형