본문 바로가기

컴퓨터 프로그래밍/javascript

onclick: javascript

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	function test1(){
		document.write("연희 안녕?");
		alert("연희안녕??");//항상 먼저 실행됩니다. 
	}
	function test2(str, name){
		var data = test3(name);
		alert(str+data);
	}
	function test3(message){
		return message+", 짱짱!!";
	}
</script>
</head>
<body>
	<input type = "button" value ="test1" onclick="test1()">
	<!--자바스크립트랑 연결 할 수 있는 속성!
		onclick,  onchange(select에 사용되는 속성입니다. 구별해서 알아둬야합니다.  -->
	<input type = "button" value ="test2" onclick="test2('우유빛깔', '김연희')">
</body>
</html>