본문 바로가기

개발하자/자바스크립트

createElement, appendChild


<html>
 <head>
 <script>
 window.onload=function(){
 b.onclick=function(){
 var fontTag=document.createElement("font");
 fontTag.color="blue";
 fontTag.innerHTML="bbb";
 bodyTag.appendChild(fontTag);
 }
 }
 </script>
 </head>
 <body id="bodyTag">
 <font color="red">aaa</font>
 <input type="button" id="b">
 </body>
</html>