Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- close together
- ajax
- Express
- css variables
- 디자인패턴
- flex-shrink
- Node.js
- Sass
- shit-christmas
- es6
- just-one-small-sip
- css
- JS
- regExp
- css 오버레이
- 정규표현식
- improve-iq-by-up-to-10%!
- Prototype
- flex-basis
- Engoo
- flexbox
- css grid
- node
- flex-grow
- select by attribute
- express-handlebars
- 무료 백엔드 배포
- Object.create
- module wrapper function
- img 확대
Archives
- Today
- Total
Creating Elements 본문
// Create element
const li = document.createElement("li");
// Add class
li.className = "collection-item";
// Add id
li.id = "new-item";
// Add attribute
li.setAttribute("title", "New Item");
// Create text node and append
li.appendChild(document.createTextNode("Hello World"));
// Create new link element
const link = document.createElement("a");
// Add classes
link.className = "delete-item secondary-content";
// Add HTML Icon
link.innerHTML = `<i class="fa fa-remove"></i>`;
// Append link into li
li.appendChild(link);
// Append li as child to ul
document.querySelector("ul.collection").appendChild(li);
console.log(li);
'2021 프론트 엔드 로드맵 따라가기 > JS' 카테고리의 다른 글
Mouse events (0) | 2021.05.31 |
---|---|
Replace & Remove Elements (0) | 2021.05.31 |
traversing dom (0) | 2021.05.30 |
Multiple Selector (0) | 2021.05.30 |
single selector (0) | 2021.05.30 |
Comments