document.getElementById() - 버튼 클릭시 style 적용 > SCRIPT

본문 바로가기

사이트 내 전체검색

뒤로가기 SCRIPT

document.getElementById() - 버튼 클릭시 style 적용

본문

<script>

function change(){

var span2 = document.getElementById("mySpan");

span2.style.color = "green";

span2.style.fontSize = "30px";

span2.style.border = "3px dotted magenta";

span2.style.margin = "30px";

}

</script>


<h3>css3 스타일 동적 변경</h3>

<hr>

<p style="color:blue">

이것은 <span id="mySpan" style="color:red">문장입니다.</span>

</p>

<input type="button" value="스타일 변경" onclick="change()">

추천0 비추천 0

댓글목록 0

등록된 댓글이 없습니다.


Copyright © dancePKT. All rights reserved.
PC 버전으로 보기