개발하자/자바스크립트
Math.ceil(Math.random() * 5);
i구야
2015. 2. 24. 14:39
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<script>
window.onload = function() {
a.onclick = function() {
b.value = Math.ceil(Math.random() * 5);
if (b.value == c.value) {
e.value = "당첨";
} else {
e.value = "꽝";
}
}
}
</script>
<input type="text" id="b">
<input type="text" id="c">
<input type="button" value="1~5까지 난수발생" id="a">
<input type="text" id="e">
</body>
</html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<script>
window.onload = function() {
a.onclick = function() {
b.value = Math.ceil(Math.random() * 5);
if (b.value == c.value) {
e.value = "당첨";
} else {
e.value = "꽝";
}
}
}
</script>
<input type="text" id="b">
<input type="text" id="c">
<input type="button" value="1~5까지 난수발생" id="a">
<input type="text" id="e">
</body>
</html>