์ด ๊ธ์ ์ค์ค๋ก ํ์ตํ ๋ด์ฉ์ ์๊ธฐ์ํค๊ณ ์ ์์ฑํ๋ ๊ธ์ด๋ฏ๋ก,
ํน์ฌ๋ ์ฝ๋๋ ์ ์๊ฐ ์๋ชป ์ธ๊ธ๋ ๋ถ๋ถ์ด ์๋ค๋ฉด,
ํผ๋๋ฐฑ ๋ถํ๋๋ฆฌ๊ฒ ์ต๋๋ค.
<๊ธฐ๋ณธ๊ฐ๋ >
HTML : ๋ผ๋
CSS : ๊พธ๋ฏธ๊ธฐ
JavaScript : ์์ง์ด๊ธฐ
HTML์ <head> ์ <body>๋ก ๊ตฌ์ฑ๋์ด์๋ค.
<head> : ๋์๋ ๋ณด์ด์ง ์์ง๋ง ์น์๋ ์ค์ํ ์ ๋ณด๋ฅผ ๋ด๊ณ ์๋ ๊ณณ,
๊พธ๋ฉฐ์ฃผ๋ CSS์ ์์ง์์ ์ฃผ๋ JavaScript๊ฐ
๋ผ๋ HTML์ <head>๋ถ๋ถ์ ๋ค์ด๊ฐ๋ค.
<TIL> / HTML, CSS, JavaScript ๋ฅผ ์จ์ ๋ง๋ค์ด๋ณธ TIL ํ์ด์ง "์ ์ฒด ์ฝ๋"
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
<title> TIL </title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Gowun+Dodum&display=swap');
* {
font-family: 'Gowun Dodum', sans-serif;
}
.mytitle {
background-color: green;
color: white;
height: 250px;
/* linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) <-- ๋ฐฐ๊ฒฝ ์ด๋ก๊ฒ ํ๊ธฐ*/
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://movie-phinf.pstatic.net/20210715_95/1626338192428gTnJl_JPEG/movie_image.jpg');
background-position: center;
background-size: cover;
/* ๋ด์ฉ๋ฌผ์ ์ ๋ ฌ์ํฌ๋๋ ๋ฐ์ 4์ค์ด ํญ์ ๊ฐ์ด ๋ค๋๋ค. ๋ฐ๋ผ์, padding์ ์ธ ํ์๊ฐ ์๋ค. */
display: flex;
flex-direction: column; /* column ์ธ๋ก, row ๊ฐ๋ก */
align-items: center;
justify-content: center;
}
/* ๊ฐ์ div ์์์๋ button์ ์ง์ ํ ๋ class๋ฅผ ๋ฌ์ง ์๊ณ ๋ฐ์ ๋ฐฉ์์ผ๋ก๋ ์ธ ์ ์๋ค.
๋ง์ฝ h1์ ์ง์นญํ๊ณ ์ถ๋ค๋ฉด ๊ธฐํธ ๋ค button ๋์ h1์ ์ง์ด ๋ฃ์ด์ฃผ๋ฉด ๋๋ค. */
.mytitle > button {
width: 250px;
height: 50px;
background-color: transparent;
/* ๋ฐฑ๊ทธ๋ผ์ด๋ ์ปฌ๋ฌ๋ฅผ ์์ ์ค๋ผ~ ๋ผ๋ ๋ป */
border: 1px solid white;
/* border๋ ํ
๋๋ฆฌ solid๋ ์ค์ */
color: white;
border-radius: 50px;
margin-top: 20px;
}
/* ์ฐธ๊ณ : hover๋ฅผ ๋ถ์ด๋ฉด ๋ง์ฐ์ค๋ฅผ ์ฌ๋ ค๋์์ ๋ ์์ด ๋ณํ๊ฑฐ๋ ํ
์คํธ์ ๋ณํ๋ฅผ ์ค ์ ์๋ค. */
.mytitle>button:hover {
border: 2px solid white;
}
.mycomment {
color: gray;
}
.mycards {
width: 1200px;
margin: 20px auto 20px auto;
}
.mypost {
width: 500px;
margin: 20px auto 20px auto;
padding: 20px;
box-shadow: 0px 0px 3px 0px gray;
/* ์ฐธ๊ณ : ์ ์ฝ๋๋ ๊ทธ๋ฆผ์์ ๊ธธ์ด๋ฅผ ์กฐ์ ํด์ฃผ๋ ์ฝ๋.
๊ฐ ์ซ์๋ ์๋, ์ ๋ฐฉํฅ์ผ๋ก๋ถํฐ ์ผ๋ง๋ ๋ฉ๋ฆฌ ๋จ์ด์ ธ ์๋์ง๋ฅผ ์๋ฏธํ๊ณ ํ์ฌ๋ ๊ฐ์ด๋ฐ์์ ์์ ์ํ.
3์ด๋ ์ซ์๋ง ๋ณ๊ฒฝํด ๊ทธ๋ฆผ์์ ๊ธธ์ด๋ฅผ ์กฐ์ ํด์ฃผ๋ฉด ๋๋ค. */
}
.mybtns {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin-top: 20px;
}
.mybtns>button {
margin-right: 10px;
}
</style>
<script>
// function hey() {
// alert('hi')
// }
// ์ ํจ์ ํด์ :
// 1. ์ํ ๊ธฐ๋ก ๋ฒํผ์ ๋๋ฅด๋ฉด hey()ํจ์๊ฐ ์๋ํ๋๋ฐ ๋ด์ฉ์?
// 2.{}์์ ๋ด์ฉ
// {}๋ณด์ alert('hi')๊ฐ ์๋ค?
// 3. ์~! ๋ฒํผ์ ๋๋ฅด๋ฉด hi๋ผ๋ ๋ฌธ์์ด ์๋ฆผ์ด ๋์ค๊ฒ ๊ตฌ๋~ ๋ผ๊ณ ํด์
// 4. ์ธ์ ?? : (<button onclick="hey()">์ํ ๊ธฐ๋ก ๋ฒํผ</button>) ์ํ! '์ํ ๊ธฐ๋ก ๋ฒํผ'์ ํด๋ฆญํ์ ๋!
// ์ฌ๊ธฐ์ onclick์ html ๊ณผ javascript๋ฅผ ์ฐ๊ฒฐ์์ผ์ฃผ๋ ๋ค๋ฆฌ์ญํ ์ ํ๋ค.
// console.log(a) : a ์ถ๋ ฅ / console.log(a[0]) : a์ 0๋ฒ์งธ ์ถ๋ ฅ
// console.log(a+b) : a+b๊ฐ ์ถ๋ ฅ / console.log(a.length) : a์ ์ ์ฒด๊ฐฏ์ ์ถ๋ ฅ
// dictionary = {} = {key : value , key : value} ๋ก ์ด๋ฃจ์ด์ ธ ์๋ค.
// dictionary๋ก ๋ถ๋ฌ์ console.log ๋ก ์ฐ์๋ log()์์ a๋ฅผ ๋ฃ๊ณ ๊บฝ์ ([])์์ dictionary์ key๊ฐ์ ์
๋ ฅํ๋ค.
// let a = {}
// ์ค๊ดํธ๊ฐ ์จ๋ค? ๊ทธ๊ฑฐ๋ dictionary
// let a = []
// ๊บฝ์ ๊ฐ ์จ๋ค? ๊ทธ๊ฑฐ๋ list
// let a = [{}]
// ๊บฝ์ ์์ ์ค๊ดํธ๊ฐ ์จ๋ค? ๊ทธ๊ฑฐ๋ list + dictionary
// ex) let a = [
// {'name':'์์','age':24}
// {'name':'์์ฒ ','age':15}
// {'name':'์ํฌ','age':21}
// ] ์ผ ๋,
// console.log(a[0]['name']) = ์์
// ์ด๋ฐ์์ผ๋ก ๊ฐ์ ์ถ๋ ฅํ ์ ์๋ค๋๊ฑธ ์ ์ ์๋ค.
$(document).ready(function () {
fetch("http://spartacodingclub.shop/sparta_api/weather/seoul").then(res => res.json()).then(data => {
$('#temp').text(data['temp'])
})
fetch("http://spartacodingclub.shop/web/api/movie").then(res => res.json()).then(data => {
let rows = data['movies']
$('#cards').empty()
rows.forEach((a)=>{
let title = a['title']
let comment = a['comment']
let desc = a['desc']
let star = a['star']
let image = a['image']
let star_image = 'โญ'.repeat(star)
// ๋ณ์ ๋ฐ๋ณต ํ๋ ์ฝ๋ ใ
ใ
let temp_html = `<div class="col">
<div class="card h-100">
<img src="${image}"
class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">${title}</h5>
<p class="card-text">${desc}</p>
<p>${star_image}</p>
<p class="mycomment">${comment}</p>
</div>
</div>
</div>`
$('#cards').append(temp_html)
})
})
})
</script>
</head>
<body>
<div class="mytitle">
<h1>๋ด ์์ ์ต๊ณ ์ ์ํ๋ค</h1>
<div>ํ์ฌ ์์ธ์ ๋ ์จ : <span id="temp">20</span>๋</div>
<button onclick="hey()">์ํ ๊ธฐ๋ก ๋ฒํผ</button>
<!-- ์ฌ๊ธฐ hey() ๋ฐ๋ ๋ฒํผ์ด ์๋ค. -->
</div>
<div class="mypost">
<div class="form-floating mb-3">
<input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">
<label for="floatingInput">์ํ URL</label>
</div>
<div class="input-group mb-3">
<label class="input-group-text" for="inputGroupSelect01">๋ณ ์ </label>
<select class="form-select" id="inputGroupSelect01">
<option selected>--โญ์ ํโญ--</option>
<option value="1">โญ</option>
<option value="2">โญโญ</option>
<option value="3">โญโญโญ</option>
<option value="4">โญโญโญโญ</option>
<option value="5">โญโญโญโญโญ</option>
</select>
</div>
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea"></textarea>
<label for="floatingTextarea">์ฝ๋ฉํธ ๋จ๊ฒจ์ฃผ์ธ์.</label>
</div>
<div class="mybtns">
<button type="button" class="btn btn-dark">๊ธฐ๋ก</button>
<button type="button" class="btn btn-outline-dark">๋ซ๊ธฐ</button>
</div>
</div>
<div class="mycards">
<div id="cards" class="row row-cols-1 row-cols-md-4 g-4">
<div class="col">
<div class="card h-100">
<img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg"
class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">์ํ ์ ๋ชฉ</h5>
<p class="card-text">์ฝ๋ฉํธ</p>
<p>โญโญโญ</p>
<p class="mycomment">๋์ ์๊ฒฌ</p>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg"
class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">์ํ ์ ๋ชฉ</h5>
<p class="card-text">์ฝ๋ฉํธ</p>
<p>โญโญโญ</p>
<p class="mycomment">๋์ ์๊ฒฌ</p>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg"
class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">์ํ ์ ๋ชฉ</h5>
<p class="card-text">์ฝ๋ฉํธ</p>
<p>โญโญโญ</p>
<p class="mycomment">๋์ ์๊ฒฌ</p>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg"
class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">์ํ ์ ๋ชฉ</h5>
<p class="card-text">์ฝ๋ฉํธ</p>
<p>โญโญโญ</p>
<p class="mycomment">๋์ ์๊ฒฌ</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
์ ์ ์ฒด์ฝ๋๋ฅผ ๋ณด๋ฉด CSS๋ HTML์ ๊ตฌ์ฑ์์์ธ <head>์์ <style>์ด๋ผ๋ ๊ณณ ์์์ ์ด๋ค์ง๊ณ ์๋ ๊ฑธ ํ์ธํ ์ ์๋ค.
๋ด๊ฐ CSS๋ฅผ ์ด์ฉํด์ ๋ฌด์ธ๊ฐ๋ฅผ ๊พธ๋ฐ๋ ค๊ณ ํ๋ค๋ฉด ???
1. ์ฐ์ '์ง์นญํ ๋์'์ด ํ์ํ๋ค.
ํ์ด์ง์ ์ ๋ชฉ๊ณผ ๋ ์จ๋ฅผ ํฌํจํ๊ณ ์๋ ๊ตฌ์ญ(div)์ ๋ด๊ฐ ๊พธ๋ฏธ๊ณ ์ถ๋ค๋ฉด
div์์ class="์๋ฌด๊ฐ" ๋ก ์ง์นญ์ ํด์ฃผ๋ฉด ๋๋ค.
์์)
<div class="mytitle">
<h1>๋ด ์์ ์ต๊ณ ์ ์ํ๋ค</h1>
<div>ํ์ฌ ์์ธ์ ๋ ์จ : <span id="temp">20</span>๋</div>
<button onclick="hey()">์ํ ๊ธฐ๋ก ๋ฒํผ</button>
<!-- ์ฌ๊ธฐ hey() ๋ฐ๋ ๋ฒํผ์ด ์๋ค. -->
</div>
๋์์ ์ง์นญํ๋ค๋ฉด?
2. <head>์ <style>๋ก ์ฌ๋ผ์ .mytitle๋ก ๋์์ ๊ฐ๋ฆฌํค๊ณ ๊พธ๋ฏธ๊ธฐ๋ฅผ ์์ํ๋ค.
<head>
<style>
.mytitle {
background-color: green;
color: white;
height: 250px;
/* linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) <-- ๋ฐฐ๊ฒฝ ์ด๋ก๊ฒ ํ๊ธฐ*/
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://movie-phinf.pstatic.net/20210715_95/1626338192428gTnJl_JPEG/movie_image.jpg');
background-position: center;
background-size: cover;
/* ๋ด์ฉ๋ฌผ์ ์ ๋ ฌ์ํฌ๋๋ ๋ฐ์ 4์ค์ด ํญ์ ๊ฐ์ด ๋ค๋๋ค. ๋ฐ๋ผ์, padding์ ์ธ ํ์๊ฐ ์๋ค. */
display: flex;
flex-direction: column; /* column ์ธ๋ก, row ๊ฐ๋ก */
align-items: center;
justify-content: center;
}
</style>
</head>
์ง์นญํ ๋์์ด (๊พธ๋ฉฐ์ค์ผ ํ ๋์์ด) div(๊ตฌ์ญ) ์ด๋ผ๋ฉด ?
1. background-color ๋ถํฐ ๋ณ๊ฒฝ
(๋ฐ์ค์ ๋ฒ์๋ฅผ ์๊ธฐ ์ํจ)
2. ๊ทธ ํ์ ์๊น๊ณผ ํฐํธ์ฌ์ด์ฆ, ๋์ด, ๋์ด ... ๋ณธ์ธ์ด ์ํ๋ ์์ ์ ํด ๋๊ฐ๋ค.
์ฐธ๊ณ : /*๋ ์ฃผ์ (๊ฐ๋ฐ์์๊ฒ ๋ณด์ด์ง๋ง, ์ปดํจํฐ์์๋ ๋ณด์ด์ง ์๋ ๋ฉ๋ชจ์ฅ ๊ฐ์ ๊ธฐ๋ฅ์ด๋ค.)
๋จ์ถํค : (Ctrl + / ), ๋ชจ์์ ๋ถ๋ ๋จ๋ฝ๋ง๋ค ๋ค๋ฅด๊ธฐ์ ๋จ์ถํค๋ฅผ ์๊ณ ์์ผ๋ฉด ์ข๋ค.
๊ทธ๋ ๋ค๋ฉด ์์ง์์ ์ฃผ๋ JavaScript์ ๊ฒฝ์ฐ์๋?
์ฐ์ JavaScript ๋ฅผ ์ฐ๋์ด์ ๋
HTML ์กฐ์ํ ๋ ค๊ณ , ์?
์์ง์ด๊ฒ ๋ง๋ค๊ณ ์ถ์ผ๋๊น, ๊ทผ๋ฐ ์์ง์์ JavaScript๋ก๋ง ์ธ๋ ค๊ณ ํ๋ฉด ์กฐ๊ธ ๋ณต์กํ๋ค.
๊ทธ๋์ ์๋๊ฒ jQuery !
<div class="mycards">
<div id="cards" class="row row-cols-1 row-cols-md-4 g-4">
<div class="col">
<div class="card h-100">
<img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg"
class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">์ํ ์ ๋ชฉ</h5>
<p class="card-text">์ฝ๋ฉํธ</p>
<p>โญโญโญ</p>
<p class="mycomment">๋์ ์๊ฒฌ</p>
</div>
</div>
</div>
JavaScript์ ๊ฒฝ์ฐ์๋jQuery ๋ฅผ ์ด์ฉํด์ id="์๋ฌด๊ฐ"๋ก ์ง์นญ์ ํ๊ณ , $('#์๋ฌด๊ฐ')๋ก ๊ฐ๋ฆฌํจ๋ค.
$('#cards').append(temp_html)
๋์ ์ฐจ์ด์ ์ ์์๋๋ฉด ์ฒ์ ์ฝ๋ฉ์ ์์ํ๋ฉด์, ์ฝ๋ ํด์ํ๊ณ ๋ถ๋ฅํ๋๋ฐ ๋์์ด ๋ง์ด ๋๋ค.
๊ตฌ๋ถ | ์ง์นญํ ๋ | ์์ฑํ๋ ๊ณณ | ๊ฐ๋ฆฌํฌ ๋ |
CSS | class="๋ฟ ๋ฟ ๋ฟ " | <style> | .๋ฟ ๋ฟ ๋ฟ |
JavaScript (jQuery) | id="๋ฟก๋ฟก๋ฟก" | <script> | $('#๋ฟก๋ฟก๋ฟก') |
์๋ฒ์์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ ํ์ฉํ ์ ์๊ฒ ํด์ฃผ๋
Fetch
fetch("http://spartacodingclub.shop/web/api/movie").then(res => res.json()).then(data => {
let rows = data['movies']
$('#cards').empty()
rows.forEach((a)=>{
let title = a['title']
let comment = a['comment']
let desc = a['desc']
let star = a['star']
let image = a['image']
let star_image = 'โญ'.repeat(star)
// ๋ณ์ ๋ฐ๋ณต ํ๋ ์ฝ๋ ใ
ใ
let temp_html = `<div class="col">
<div class="card h-100">
<img src="${image}"
class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">${title}</h5>
<p class="card-text">${desc}</p>
<p>${star_image}</p>
<p class="mycomment">${comment}</p>
</div>
</div>
</div>`
$('#cards').append(temp_html)
})
})
์ค๋ ์ด๊ฑฐ ์์ฑํ๊ณ ํด์ํ๋๋ฐ๋ง ์ผ๋ง๋ ๊ฑธ๋ ธ๋์ง.....
Fetch๋ฅผ ์ด์ฉํ๋ฉด ์๋ฒ๋ก๋ถํฐ ๋ฐ์ดํฐ๋ฅผ ์น ๊ฐ์ง๊ณ ์์
์ฝ๋์์ ์ด์ฉํ ์ ์๋ค.
Fetch ๊ณจ๊ฒฉ ์์)
fetch("์ฌ๊ธฐ์ URL์ ์
๋ ฅ").then(res => res.json()).then(data => {
console.log(data)
})
ํด์ : fetch๋ "์ ๋ ฅํ URL"๋ก๋ถํฐ ์ ๋ณด๋ฅผ ๋ฐ์์ค๋๋ฐ,
res(=result๋ ๊ฐ์ ๋ง)๋ฅผ jsonํํ๋ก ๊ฐ์ ธ์ฌ๊ฑฐ์ผ,
๊ทธ๋ฆฌ๊ณ ์ฐ๋ฆฐ ๊ทธ data๋ฅผ {}๋งํผ ํ์ฉํ ๊ฑด๋ฐ,
{}์ ๋ญ์์ด?? console.log(data) !!
์~ "์ ๋ ฅํ URL"๋ก๋ถํฐ jsonํํ๋ก ๋ฐ์์จ data๋ฅผ console.log(data)๋ก ์ฐ์ด๋ณธ๋ค๋ ์๋ฆฌ๊ตฌ๋~
๋ผ๊ณ ํด์ํ๋ ์๊ฐ ๋ด๊ฐ fetch์ฝ๋๋ฅผ ์ ์ผ๋ฉด์ ์ฝ๋ฉ์ด ๋ณด๋ค ํธํด์ก๋ค๋๊ฑธ ๊นจ๋ฌ์ ์ ์์๋ค.
์ํ~ ๊ทธ๋์ jsonํํ๋ก ๋ฐ์์ค๋๊น ์ฐ๋ฆฌ๋ ๊ทธ๊ฑธ ๋์ดํ๊ณ ์ถ์ ๊ฑฐ๊ณ !
์ ๊ทธ๋ฌ๋ฉด forEach๊ฐ ์ค๊ฒ ๊ตฌ๋~
๊ทธ๋ฌ๋ฉด forEach์์ ๋ณ์๊ฐ ๋ค์ด๊ฐ๋๊น
๋ฐ์์จ data์ ๋ฌด์ธ๊ฐ๋ฅผ ๋ณ์๋ก ์ก๊ณ ,
์ฐ๋ฆฌ๊ฐ ์ํ๋ ์ ๋ณด๋ฅผ ์์์ ๊ฐ๋ค ๋ถ์ด๋ฉด ๋๊ฒ ๋ค??
๋ด๊ฐ ํ์ํ๊ฑด 1.์ํ์ ๋ชฉ, 2.๊ฐ์ํ, 3.๋์ ์๊ฒฌ, 4.๋ณ์ , 5.ํฌ์คํฐ์ฌ์ง ์ด๋๊น
๊ณ ๊ฒ๋ง ์์ ๋นผ์์ temp_html๋ง๋ค๊ณ ๊ทธ๊ฑธ append๋ก ๋ถ์ฌ์ฃผ๋ฉด ๋๊ฒ ๊ตฌ๋~?
fetch("http://spartacodingclub.shop/web/api/movie").then(res => res.json()).then(data => {
let rows = data['movies']
$('#cards').empty()
rows.forEach((a)=>{
let title = a['title']
let comment = a['comment']
let desc = a['desc']
let star = a['star']
let image = a['image']
let star_image = 'โญ'.repeat(star)
// ๋ณ์ ๋ฐ๋ณต ํ๋ ์ฝ๋ ใ
ใ
let temp_html = `<div class="col">
<div class="card h-100">
<img src="${image}"
class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">${title}</h5>
<p class="card-text">${desc}</p>
<p>${star_image}</p>
<p class="mycomment">${comment}</p>
</div>
</div>
</div>`
$('#cards').append(temp_html)
์ค๋์ Fetch์ jQuery , ๋ณ์ ๋ง๋ค๊ธฐ , ํด์ํ๊ธฐ,
์๊ตฌ์ฌํญ์ ๋ณด๊ณ ๋ ์ค์ค๋ก ๋จผ์ ์ฝ๋ฉํด๋ณด๊ธฐ๋ฅผ ๊ฐ์ฅ ์ค์ ์ ์ผ๋ก ํ๋ฉด์
์ด์ ๋ณด๋ค ๋ ํฅ๋ฏธ๋ฅผ ๊ฐ์ง๊ฒ ๋ ๊ฒ ๊ฐ๋ค.
์ต์ง๋ก ๋จธ๋ฆฟ์์ ์ง์ด๋ฃ์๋ ๋ถ๋ถ์ ์ด์ ์์ผ ์ฒ์ ์ดํด๋ฅผ ํ๊ธฐ ์์ํ๋
์ด์ ๋ง ์ฝ๋ฉ์ ์ธ๊ณ์ ๋ฐ์ ๋ค์ฌ๋์ ๋ ์ด์ง๋ง
๋๋ฌด๋๋ ์๋กญ๊ณ ์ฌ๋ฐ๋ค ใ ใ

์๋ฌดํผ ๋ชฐ๋ผ๋ ์ฒ์ฒํ
๋๋ ค๋ ๊พธ์คํ๊ฒ
๊ทธ๋ ๊ฒ ๋์๊ฐ๊ณ ์ ํ๋ค.
Good bye
' ใ '