[리액트] 중괄호는 언제 사용하나요
IT/React 2021. 1. 9. 12:43

For instance, because JSX is a syntactic extension of JavaScript, you can actually write JavaScript directly within JSX. To do this, you simply include the code you want to be treated as JavaScript within curly braces: { 'this is treated as JavaScript code' }. Keep this in mind, since it's used in several future challenges. 출처: freecodecamp.org ​ JSX는 JavaScript + HTML이다. JSX에서 자바스크립트 코드는 {} (cu..

[자바스크립트] localStorage 데이터 저장/삭제 해결 방법
IT/JavaScript 2021. 1. 7. 22:56

이전에 TO DO LIST와 유사한 쇼핑목록 웹사이트를 만들었다. 입력, 삭제가 가능하지만 페이지를 새로고침 하면 사라졌다. ​ [JavaScript] (해결) 동적으로 font awesome 아이콘 추가하기 나는 쇼핑목록 앱을 만들고있다. TO DO LIST처럼 쇼핑할 물건들을 적는 리스트이다. 현재 문제점 : appendChild, innerHTML 등을 이용하여 font awesome icon을 추가하려한다. 이런식으로. 다만 x 표시(빨간색 breathtaking-life.tistory.com 이제는 더 나아가 페이지를 새로 고침해도 데이터가 남아 있게 만들고 싶었다. 구글링 해보니 localStorage가 있었다. 참고: Window.localStorage - Web APIs | MDN The ..

[자바스크립트] innerText 와 textContent 차이점
IT/JavaScript 2021. 1. 6. 18:18

​ innerText의 Syntax const renderedText = htmlElement.innerText htmlElement.innerText = string textContent의 Syntax let text = someNode.textContent someOtherNode.textContent = string MDN에 innerText와 textContent 비교한게 있다. (출처 게시글 밑 참고) ​ HTML: Source element: #source { color: red; } Take a look athow this textis interpreted below. HIDDEN TEXT Result of textContent: ... Result of innerText: ... 자바스크립..

[자바스크립트] 버블링과 캡쳐링
IT/JavaScript 2021. 1. 5. 00:21

캡처링 단계 – 이벤트가 하위 요소로 전파되는 단계 버블링 단계 – 이벤트가 상위 요소로 전파되는 단계 body * { margin: 10px; border: 1px solid blue; } FORM DIV P 가장 안쪽의 를 클릭하면 순서대로 다음과 같은 일이 벌어집니다. 에 할당된 onclick 핸들러가 동작합니다. 바깥의 에 할당된 핸들러가 동작합니다. 그 바깥의 에 할당된 핸들러가 동작합니다. document 객체를 만날 때까지, 각 요소에 할당된 onclick 핸들러가 동작합니다. ​ ​ 즉 p->div->form 순서로 창이 열린다. 이러한 흐름을 '이벤트 버블링'이라고 한다. (거의 모든 이벤트들은 버블링이 일어난다. focus()같은 이벤트를 제외하면.) ​ Introduction to e..

[JavaScript] 렌더링 트리(Critical Rendering Tree)
IT/JavaScript 2021. 1. 3. 22:58

카테고리가 JavaScript에 국한된 건 아니지만, 이미 카테고리를 세부적으로 나누었기에 여기에 업로드! ​ 렌더링 트리 생성, 레이아웃 및 페인트 | Web | Google Developers TODO developers.google.com ​ *Critical Rendering Path ​ * Render Tree 형성은 DOM, CSSOM의 결합 * DOM Tree에서 - 일부 노드는 표시되지 않으며(예: 스크립트 태그, 메타 태그 등), 렌더링된 출력에 반영되지 않으므로 생략됩니다. - 일부 노드는 CSS를 통해 숨겨지며 렌더링 트리에서도 생략됩니다. 예를 들어,---위의 예시에서---span 노드의 경우 'display: none' 속성을 설정하는 명시적 규칙이 있기 때문에 렌더링 트리에서 누..

[JavaScript] clientX/Y, pageX/Y, MouseEvent
IT/JavaScript 2021. 1. 1. 18:30

-clientX, clientY는 window 창에서 시작다. -pageX, pageY는 page의 제일 상위부터 시작한다. (페이지의 시작점부터) MouseEvent.clientX - Web APIs | MDN The clientX read-only property of the MouseEvent interface provides the horizontal coordinate within the application's viewport at which the event occurred (as opposed to the coordinate within the page). For example, clicking on the left edge of the viewpo developer.mozilla.org ..

[JavaScript] document.querySelector
IT/JavaScript 2021. 1. 1. 00:32

* document.querySelector(css 선택자) ​ Syntax: element = document.querySelector(CSS selectors); - name, id 를 제한 X - css선택자로 요소를 찾는다. ​ - This string must be a valid CSS selector string; if it isn't, a SYNTAX_ERR exception is thrown ​ ​ * document.querySelectorAll(css 선택자) ​ Syntax: element = document.querySelectorAll(CSS selectors); ​ 기능과 사용법은 document.querySelector와 동일하지만, css 선택자를 사용하여 모든 요소를 찾는다..

[JavaScript] 객체 기본
IT/JavaScript 2020. 12. 31. 22:32

객체 : 관련된 데이터나 함수의 집합 객체 안에서는 데이터를 프로퍼티(속성), 함수를 메소드라고 한다. ​ let person = { name: ['Bob', 'Smith'], age: 32, gender: 'male', interests: ['music', 'skiing'], bio: function() { alert(this.name[0] + ' ' + this.name[1] + ' is ' + this.age + ' years old. He likes ' + this.interests[0] + ' and ' + this.interests[1] + '.'); }, greeting: function() { alert('Hi! I\'m ' + this.name[0] + '.'); } }; 이 예시에서 프..

[JavaScript] Switch language button
IT/JavaScript 2020. 12. 31. 17:38

codepen.io/JFeremy/post/switch-language-button-js Switch language button JS switch language Script to change language in website with button. You only need a button to choose language and add "id" in balise to inform... codepen.io 자바스크립트를 이용하여 버튼을 눌렀을 때 특정 언어로 바꾸기 - Script to change language in website with button. - You only need a button to choose language and add "id" in balise to inform abou..

[JavaScript / 생활코딩] Ajax
IT/JavaScript 2020. 12. 31. 17:06

· Ajax - Ajax is a set of web development techniques using many web technologies on the client side to create asynchronous web applications. (출처:위키피디아) - 즉, JavaScript와 XML을 이용한 비동기적 정보 교환 기법 ​ - Ajax로 현재 페이지의 화면 전환 없이 서버에서 데이터 자료를 전송 가능 - 새로 고침이나 새로운 HTML 페이지로 전환이 필요 없다. - 부분만 로딩이 되므로 속도가 빠르다. ​ ​ JavaScript 선행학습이 필요하다. (무조건) ​ 생활코딩 강의를 들으며 이고잉님이 항상 강조하던 것은 중복의 제거이다. (+ 쪼개기) 이 수업 또한 중복을 제거해 나간다..