<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
<script>
//입력
// var name = prompt('input your name');
//처리
// var str = "<h2>What is your name? Hello "+name+ ", nice to meet you!<h2>";
//랜덤 배열
var textArray = [
'호 키 포키! ',
'아빠 상어 뚜루뚜뚜루',
'뚜뚜뚜와 뚜뚜뚜뚜와뚜와!'
]
var randomNumber = Math.floor(Math.random() *textArray.length);
//출력
$(document).ready(function(){
$('#foo').append('<h2>What is your name? <br> Hello '+ prompt('input your name')+ ', nice to meet you!<h2> <br>'+textArray[randomNumber]);
});
</script>
</head>
<body>
<div id="foo">
</div>
</body>
</html>
이름을 입력받는것은 변수없이 구현
댓글 없음:
댓글 쓰기