JavaScript

210923_event+button+confirm+prompt

요옫 2021. 9. 23. 12:45

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

<style type="text/css">

#out{

    position: absolute;

    left: 20px;

    top: 100px;

    background: #ffc;

    padding: 10 10 10 10;

    width: 300px;

    height: 100px;

    border: 1px solid gray;

}

</style>

 

<script type="text/javascript">

  function test1(a) {

alert(a+100);

}

  function test2(str) {

alert("문자열["+str+"]을 받았어요!");

}

  function test3() {

var a=confirm('데이터를 추가할까요?');

/* true값이 1, false는 2 */

if (a==1) 

out.innerHTML='추가했습니다';

else 

out.innerHTML='취소했습니다';

 

}

  function test4() {

var name=prompt("당신의 이름은 무엇입니까?", "");

//document.write("나의 이름은 "+name+" 입니다");

out.innerHTML="나의 이름은 "+name.fontcolor('magenta')+" 입니다";

}

 

</script>

</head>

<body>

<input type="button" value="alert_Num" onclick="test1(100)">

<input type="button" value="alert_String" onclick="test2('Hello')">

<input type="button" value="confirm" onclick="test3()">

<input type="button" value="prompt" onclick="test4()">

 

<div id="out"></div>

</body>

</html>

 

 

 

첫번째 버튼

 

두번째 버튼

 

세번째 버튼

 

세번째 버튼_2

 

 

네번째 버튼

 

네번째버튼_2

 

 

'JavaScript' 카테고리의 다른 글

210923_settimeout  (0) 2021.09.23
210923_jsp+  (0) 2021.09.23
210923_Event+confirm  (0) 2021.09.23
210923_event  (0) 2021.09.23
210923_button  (0) 2021.09.23