[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
'HTML + CSS + JS > JS ์๋ฐ์คํฌ๋ฆฝํธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JS] ํจ์ return, ์ฌ๊ทํจ์ ์ฐ์ต๋ฌธ์ (0) | 2021.10.27 |
---|---|
[JS] ํจ์,arguments ์ฐ์ต๋ฌธ์ (0) | 2021.10.27 |
[JS] ๋ธ๋ผ์ฐ์ ๊ฐ์ฒด ๋ชจ๋ธ (0) | 2021.10.26 |
[JS] ๊ฐ์ฒด ์ข ๋ฅ_ ๋ด์ฅ ๊ฐ์ฒด (Date, String, Array, Math) ์ฐ์ต๋ฌธ์ (0) | 2021.10.26 |
[JS] ์ ํ๋ฌธ(switch)์ ๋ฐ๋ณต๋ฌธ(while, do-while, for) ์ฐ์ต๋ฌธ์ (0) | 2021.10.26 |