본문 바로가기

웹코딩 배우기293

CSS - letter-spacing / h 글자간격 See the Pen letter-spacing by nilgi (@nilgi) on CodePen. 마이너스 값을 쓸 수 있습니다. 2022. 12. 14.
for 반복 - 자바스크립트 See the Pen 반복 by nilgi (@nilgi) on CodePen. • for 사용 X name1[0] + " " + name1[1] + " " + name1[2] + " " + name1[3] + " " + name1[4] + " "; • for 사용 let text = ""; for (let n = 0; n 2022. 12. 13.
switch() - 자바스크립트 See the Pen switch by nilgi (@nilgi) on CodePen. • switch : 조건(case)을 나열하고 맞는 값이 있으면 해당 내용을 표시 - case는 하나로 묶어 적용할 수 있다. 두가지 조건을 걸어 표시할 내용은 하나로 한다. - swith는 ===(값과 형식 모두 같음) 속성이다. • break : 조건에 맞으면 중단하고 값을 표시 • default : 조건에 맞는 값이 없을 때 표기할 기본 값 - default가 먼저 나오면 뒤에 조건을 적용하지 않으며 default가 가장 뒤에 나올 필요는 없다. 2022. 12. 8.
if, else, esle if - 자바스크립트 See the Pen if, else, else if by nilgi (@nilgi) on CodePen. • if - 값이 조건에 맞으면 다음 명령어 실행 • else - 값이 if를 통과하지 못하면 다음 명령어 실행 • else if - 값이 if를 통과하지 못하면 새로운 조건을 부여 2022. 12. 6.
자바스크립크 - 비교와 연산 See the Pen 비교와 연산 by nilgi (@nilgi) on CodePen. == : 값이 같은지 확인 // true, false === : 값과 유형이 모두 같은지 확인 != : 값이 다른지 확인 !== : 값과 유형이 모두 다른지 확인 >, =, 2022. 12. 1.
Boolean() 참, 거짓 See the Pen Boolean() by nilgi (@nilgi) on CodePen. • Boolean() 참(ture), 거짓(false)을 판단한다 document.getElementById("bl1").innerHTML = Boolean(1 < 2); document.getElementById("bl2").innerHTML = 1 < 2; • 다음의 경우 true "24는 " + Boolean(24) + " " + // true "-11는 " + Boolean(-11) + " " + // true "비어 있지 않는 모든 문자는 " + Boolean("티스토리") + " " + // true "'false'문자도 " + Boolean('false') + " " + // true "0을 제외한 .. 2022. 11. 29.
Math.random() - 자바스크립트 See the Pen Math.random() by nilgi (@nilgi) on CodePen. Math.random()은 0~1 사이 난수를 표시하는데 다른 명령어와 사용하여 랜덤한 정수를 표시할 수 있다. • Math.random() + Math.floor() document.getElementById("mrmf").innerHTML = Math.floor(Math.random() * 10); document.getElementById("mrmf1").innerHTML = Math.floor(Math.random() * 10) + 3; • Math.random() + min, max getRndInteger(0,24) function getRndInteger(min, max) { return Ma.. 2022. 11. 25.
Math 수학 - 자바스크립트 See the Pen Math by nilgi (@nilgi) on CodePen. ▶ Math는 개채가 필요하지 않다. • Math.round() 가까운 정수로 반환 document.getElementById("mr1").innerHTML = Math.round(5.6); • Math.ceil() 올림 document.getElementById("mc1").innerHTML = Math.ceil(7.2); • Math.floor() 버림 document.getElementById("mf1").innerHTML = Math.floor(6.2); • Math.trunc() 정수 부분 반환 document.getElementById("mt1").innerHTML = Math.trunc(3.2); • Math.. 2022. 11. 22.
text-decoration See the Pen text-decoration by nilgi (@nilgi) on CodePen. • 위치 text-decoration-line: none; text-decoration-line: overline; text-decoration-line: line-through; text-decoration-line: underline; text-decoration-line: overline underline; text-decoration-line: overline line-through underline; • 색 text-decoration-color: red; text-decoration-color: rgb(30, 144, 255); • 모양 text-decoration-style: solid; .. 2022. 11. 17.
자바스크립트 - setDate로 날짜 직접 지정하기 See the Pen setDate() by nilgi (@nilgi) on CodePen. • setFullYear() : 년 지정 sfy_d.setFullYear(2024); // 나머지 월, 일 및 요일, 시간은 오늘로 표시 sfy_d2.setFullYear(2024, 2, 24); // 월, 일 지정 • setMonth() : 월 지정 sfm_d.setMonth(1); // 월은 0~11입니다. 자바는 0부터 시작 • setDate() : 일 지정 sfd_d.setDate(24); sfd_d2.setDate(sfd_d2.getDate() + 100); // 일을 더하여 기념일 계산 • setHours() : 시 지정 sfh_d.setHours(9); • setMinutes() : 분 지정 sfmi.. 2022. 11. 15.
Date 메소드 See the Pen Date 메소드 by nilgi (@nilgi) on CodePen. • getFullYear() // 연도를 4자리로 표시 const y = new Date(); document.getElementById("gfy").innerHTML = y.getFullYear(); • getMonth() // 월 const m = new Date(); document.getElementById("gm").innerHTML = m.getMonth() + 1; // 자바스크립트는 0부터 시작이므로 +1 const ms_text = ["January","February","March","April","May","June","July","August","September","October","Nove.. 2022. 11. 10.