[JS] ๊ฐ์ฒด ์—ฐ์Šต๋ฌธ์ œ 1, 2

2021. 10. 26. 16:19ใ†HTML + CSS + JS/JS ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ

728x90

* ์—ฐ์Šต๋ฌธ์ œ 1

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset = "UTF-8">
<title> ๊ฐ์ฒด </title>
<script>
	var phoneNum = "010-2345-1234";
	var result_1 = phoneNum.substring(0,9);
	document.write(result_1, "**** <br>");

	var imgSrc = "images/bnt_out.jpg";
	var result_2 = imgSrc.replace("out", "over" );
	document.write(result_2, "<br>");
</script>
</head>
<body>
</body>
</html>

 

 

* ์—ฐ์Šต๋ฌธ์ œ 2 

5๊ฐ€์ง€์˜ ๋ฉ”๋‰ด ์ค‘์— ๋žœ๋ค์œผ๋กœ ๋ฉ”๋‰ด ๊ณจ๋ผ์ฃผ๊ธฐ 

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset = "UTF-8">
<title> ๊ฐ์ฒด </title>
<script>
		var menu = ["์งœ์žฅ๋ฉด", "๋ˆ๊ฐ€์Šค", "๋œ์žฅ๊ตญ", "๊น€์น˜์ฐŒ๊ฐœ", "ํšŒ๋ฎ๋ฐฅ"];
		var menuNum = Math.floor(Math.random() * menu.length );
		var result = menu[menuNum];
		document.write( result );
</script>
</head>
<body>
</body>
</html>
728x90