웹 & 프레임워크 168

JavaScript 노드 삭제하기

function removeNode(){/* var page = document.getElementById("sample_page"); page.removeChild(document.getElementById("content")); */ var content = document.getElementById("content"); content.parentNode.removeChild(content); } 이런식으로 첫번째놈은 부모가 뭔지 아는거고,뒤에쪽은 content의 부모의 이름이나 그런걸 모를 때, 자신의 ID를 얻어와서부모를 찾아서 다시 자기를 거시기 한다.

JavaScript 노드추가

function addTextNode(){ var content = document.getElementById("content"); var newTextNode = document.createTextNode("추가내용"); content.appendChild(newTextNode); //글자에는 못꾸민다. 꾸미려면 elementNode에만 그런거 추가가능 } 얘는 그냥 데이타다 꾸미려고 착각하지 마 function updateTextNode(){ var header = document.getElementById("header"); header.firstChild.nodeValue = "hi"; } 텍스트 바꾸는건 일단 부모를 찾는다. 바로 접근하는건 어렵기 때문. 따라서 그놈의 엘리먼트를 찾아서 첫번째놈..

[CSS] 장치에 맞게 화면을 바꿔주는 스타일 태그

@media screen and (max-width: 767px) { html { background: red; color: white; font-weight: bold; } } @media screen and (min-width: 768px) and (max-width: 979px) { html { background: green; color: white; font-weight: bold; } } @media screen and (min-width: 980px) { html { background: blue; color: white; font-weight: bold; } } 모바일의 경우는 가로, 세로도 설정해주어야 할 필요가 있껬다. @media screen and (orientation: portr..