-
자바 스크립트로 요소의 스타일 변경코딩/HTML5 2018. 6. 6. 00:35반응형<!DOCTYPE html><html><head><meta charset "UTF-8"></head><body><p id="p1">This is a paragraph.</p><script>function changeStyle() {document.getElementById("p1").style.color = "blue";document.getElementById("p1").style.fontFamily = "Georgia"document.getElementById("p1").style.fontStyle = "italic"}</script><input type="button" onclick="changeStyle()" value="눌러보세요" /></body></html>
결과:
'눌러보세요' 버튼을 누르면 This is a paragraph라는 글자의 색, 글씨체, 기울림이 바뀐다.
반응형