Case 5- node operation dynamically created elements

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <div id="box">
    <div>111</div>
  </div>
  <script>
    =the p-varcreate a DOM object in memory//
    document.createElement ( ' p ' );
     // set the object attribute 
    p.innerText =  ' Hello ' ; 
    p.style.color =  ' Red ' ; 

    // the p element, into DOM tree 
    var Box = document.getElementById ( ' Box ' ); 
    box.appendChild (P); 

  </ Script > 
</ body > 
</ HTML >

 

Guess you like

Origin www.cnblogs.com/jiumen/p/11412324.html