전체 글 198

addEventListener의 또다른 방식 html 적인 방식 onclick="js:"

방법1. addEventListener const button = document.querySelector(".container button"); const main = document.querySelector("#main"); const qna = document.querySelector("#qna"); const result = document.querySelector("#result"); function begin() { main.style.display = "none"; qna.style.display = "block"; } button.addEventListener("click", begin); 방법2. in html 시작하기 https://homzzang.com/b/js-1317 홈짱닷컴 홈페..

STUDY/Java Script 2023.11.23

[idea] 사용자의 기기(pc, mobile) 이 다크 모드인지 아닌지 알 수 있으면 좋지 않을까?

사용자의 기기(pc, mobile) 이 다크 모드인지 아닌지 알 수 있으면 좋지 않을까? 이를 미리 알 수 있다면, 다크 모드일 때와 아닐 때를 구분하여 각각 색깔을 줄 수 있지 않을까 하는 게 내 생각이다. 이게 잘 됐으면 좋겠다. 조금 더 복잡해지더라도. https://seukjjang.tistory.com/7 CSS prefers-color-scheme: 사용자 운영체제의 다크모드 탐지하기 요즘 많은 사이트에서 사용자 경험을 높이기 위해 다크모드를 지원한다. 유튜브의 경우 사용자가 일일히 다크모드로 변경할 필요 없이, 기기에 설정된 테마에 따라 자동으로 테마가 설정되는 seukjjang.tistory.com

STUDY/Java Script 2023.11.23

var, let, const 차이점

일단 자바스크립트는 호이스팅을 채택하고 있다. 변수를 언제 어느 위치에서 선언해서 사용하더라도 선언은 맨위에서 된다. 이 때 값이 주어지지 않을 경우 var는 undefined 형태가 되고, let은 선언하기 전에 사용하려고 하면 reference error 가 뜨며, const 는 오류가 뜬다. 심플하다. 보통 어떤 변수를 한 번 선언하면 재선언은 불가능하다고 생각하기 마련이지만, var 라는 놈은 더 이전에 만들어져서 그런가 재선언이 가능하다. 그래서 코드가 길어지면 호이스팅에 의해서 혹은 선언했던 것을 까먹거나 하는 이유로 예기치 못한 변수가 생길 수 있다. var testVar = "Hi"; var testVar = "Hello"; 이런 게 가능하기 때문이다. 보통은 이렇게 생각하기 마련이니까....

STUDY/Java Script 2023.11.23

nth-child(), first-child, second-child, last-child.

이 호기심은 first-child로부터 비롯되었다. dcoument.querySelector()를 통해 얻어낸 배열들 중의 첫번째 아이를 first-child 라는 의사코드(pseudo code) 를 사용하고, 마지막은 last-child 를 사용한다. 그렇다면, 두 번째 세 번째 .... 는 second-child, thrid-child... 인가? 아니다! 없다. 왜냐하면 처음과 끝은 굉장히 명백한 표현이고, 그 사이의 2번째 3번째 4번째.. 이렇게 만들다 보면 의사코드가 무제한으로 늘어날 것이기에, 간단하게 n번째 아이라고 표현하면 된다. Nth child. n번째 자녀! 이게 바로 이 의사코드의 정확한 의미 아니겠는가. nth-child. nth-child 를 활용하는 데에는 몇 가지 방식이 있..

STUDY/Java Script 2023.11.22

Friends Season 1 Episode 1 Script a little bit

How much Barry looks like Mr. Potato Head. You know, I mean, I always knew he looked familiar, but.. Anyway, I just had to get out of there and I started wondering ‘Why am I doing this?’ and ‘Who am I doing it for?’ So anyway, I just didn’t know where to go and I know that you and I have kinda drifted apart, but you’re the only person I knew who lived here in this city. Who wasn’t invited to the..