study/TIL(4)
-
JavaScript array - push () , pop() , slice() , splice()
push() 배열의 끝에 하나이상의 요소를 추가하고 , 배열의 새로운 길이를 반환 *원본 배열을 바로 수정 * const fruits = ['apple', 'banana', 'avocado', 'lemon', 'cherry']; const count = fruits.push('kiwi'); console.log(count); // expected output: 6 console.log(fruuits); // expected output: Array ['apple', 'banana', 'avocado', 'lemon', 'cherry', 'kiwi']; fruits.push('orange', 'grape'); console.log(animals); // expected output: Array [['app..
2020.07.07 -
Document. querySelector()
정의 Document.querySelector() 은 제공한 선택자나 선택자뭉치와 일치하는 문서 내 첫번째 element 를 반환한다. 일치하는 요소가 없으면 null 을 반환한다. 구문 document.querySelector(selectors); 선택자로 DOM요소를 선택해야 한다. 아닐경우 SYNTAX_ERR 가 발생한다. css 표준 구문이 아닌 문자일경우 역슬래시로 이스케이프 JavaScript또한 역슬래시로 이스케이프 해야함 예제 클래스를 만족하는 첫번째 요소 검색 var el = document.querySelector(".myclass"); 복잡한 선택자 var el = document.querySelector("div.user-panel.main input[name=login]"); Do..
2020.07.05 -
Javascript - event listener/ addEventListener
event listener window.onclick = function(){ alert('I\'m clicked')' }; 위의 코드가 대표적인 이벤트리스너 코드이다. window가 click 될때 function부분이 실행된다 window가 click 됐다는것을 browser가알려준다. 이벤트 리스너는 항상 on + '이벤트명' 으로 명명된다. 여러가지 태그에 이벤트를 설정할 수 있다 . ( 모든 DOM들 ) 자주쓰이는 이벤트 목록 onblur (객체가 포커스를 잃었을때) onchange(객체의 내용이 바뀌고 포커스를 잃었을때 ) onclick (객체를 클릭했을때 ) ondbclick ( 객체를 더블클릭 했을때) onerror(에러가 떴을떄) onfocus(객체에 포커스 되었을때 ) onkeydown..
2020.07.05 -
HTML - style , script 태그
HTML style tag https://www.freecodecamp.org/news/inline-css-guide-how-to-style-an-html-tag-directly/ Inline CSS Guide – How to Style an HTML Tag Directly You’ve written some HTML and now need to style it with CSS. One way is to use inline styles, which is what this article is about. This is my first paragraph. Before we jump into the nuances of inline styles—w www.freecodecamp.org 링크를 이용해서 외부 CS..
2020.07.04