Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags more
Archives
Today
Total
관리 메뉴

기록

자바스크립트 로또생성 (파이썬5) 본문

JAVASCRIPT&JQUERY

자바스크립트 로또생성 (파이썬5)

9400 2023. 1. 10. 14:32
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">

function myclick(){
	let lotto =[1,2,3,4,5,6,7,8,9,10,
            11,12,13,14,15,16,17,18,19,20,
            21,22,23,24,25,26,27,28,29,30,
            31,32,33,34,35,36,37,38,39,40,
            41,42,43,44,45];
	
	for(i=0; i<10000; i++){
	let rnd = Math.floor(Math.random() * lotto.length);
		a = lotto[rnd];
		b = lotto[0];
		lotto[0] = a;
		lotto[rnd] = b;
	}
	
	let mytd = document.querySelectorAll(".mytd");
	console.log(lotto[0]);
	console.log(lotto[1]);
	
 	mytd[0].innerText = lotto[0];
 	mytd[1].innerText = lotto[1];
	mytd[2].innerText = lotto[2];
	mytd[3].innerText = lotto[3];
	mytd[4].innerText = lotto[4];
	mytd[5].innerText = lotto[5];  
}

</script>
</head>
<body>
<table>
	<tr>
		<td class="mytd">__</td>
		<td class="mytd">__</td>
		<td class="mytd">__</td>
		<td class="mytd">__</td>
		<td class="mytd">__</td>
		<td class="mytd">__</td>
	</tr>
	<tr >
		<td colspan="6">
			<input type="button" value="로또생성하기" onclick="myclick()"/>
		</td>
	</tr>

</table>
</body>
</html>

 

출력 성공

 

Comments