HTML.CSS.JS/JS 127

[JS] day13_fetch json데이터 가져와서 원하는 모양으로 출력하기

DOCTYPE html> Document @font-face { font-family: 'KCCChassam'; src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2302@1.0/KCCChassam.woff2') format('woff2'); font-weight: normal; font-style: normal; } body{ font-family: 'KCCChassam'; background-color: rgb(255, 249, 252); } header{ text-align: center; margin: 50px 0; } header>img{ width: 280px; height: 200px; } header>h1{ color: rgb(2..

HTML.CSS.JS/JS 2023.04.20

[JS] day13_non_standard 비표준 속성

DOCTYPE html> 비표준 속성 let li_last_tag = document.querySelectorAll('.list'); console.log(li_last_tag); //NodeList console.log(li_last_tag[0].dataset.ino); //0번지의 ino값 : li_last let liLast = li_last_tag[0].dataset.ino; //0번지의 ino값 : li_last console.log(liLast); console.log(li_last_tag[0].dataset.itemcategory); // 대문자로 작성해도 소문자로 읽음 = 소문자 작성하세요(대문자x) // 0번지의 itemcategory값: litop

HTML.CSS.JS/JS 2023.04.20

[JS] day13_async_promiseChain 데이터 가져오기 2

Promise Chain 방식 데이터 가져오기 document.getElementById('btn').addEventListener('click',()=>{ // fetch('https://jsonplaceholder.typicode.com/todos/1') //데이터 가져와서 // .then(resp => resp.json()) //1. 매개변수 resp에 json형식으로 데이터를 넣고 리턴 // .then(json => console.log(json)); //콘솔에 찍어라 // .catch(err=> console.log(err)); //실패시 // .then(resp => resp.text()) //2. 매개변수 resp에 text형식으로 데이터를 넣고 리턴 // .then(text => conso..

HTML.CSS.JS/JS 2023.04.20

[JS] day13_async_await 데이터 불러오기

DOCTYPE html> async await 데이터 불러오기 document.getElementById('btn').addEventListener('click',()=>{ async function awaitEx(){ try{ const resp = await fetch('https://jsonplaceholder.typicode.com/todos/1'); // resp = response 응답 // 받아서 저장하는 경우 ) 원하는 사용에 따라 text(),json()으로 저장! const result = await resp.text(); // 1. resp를 text로 받아 저장 -> type = string const result1 = await resp.json(); // 2. resp를 json..

HTML.CSS.JS/JS 2023.04.20

[JS] 구구단 ( 문제 출력 -> 맞추기 -> 결과 출력 )

HTML 삽입 미리보기할 수 없는 소스 DOCTYPE html> 구구단 맞추기 문제는 10문제 출제 맞추면 blue / 틀리면 pink 정답률도 프린트 문제 출제 정답! // 랜덤 단 function makeDan(){ return Math.floor(Math.random()*8)+2; } // 랜덤 곱할 숫자 function makeNum(){ return Math.floor(Math.random()*9)+1; } let comAns = []; //정답을 담는 배열 생성 let printQuiz = document.getElementById('q'); //문제 출제 document.getElementById('start').addEventListener('click',()=>{ let str=" "; ..

HTML.CSS.JS/JS 2023.04.20