日期:2014-05-16  浏览次数:20254 次

javascript 节点的问题
<HTML>
 <HEAD>
  <script>
  function reverse(e)
{  
  var f = document.createDocumentFragment();
  while(e.lastChild) f.appendChild(e.lastChild);
e.appendChild(f);
}
  window.onload = function()
  {
  var e = document.getElementById('press');
var press = document.getElementsByTagName("input")[0];
press.onclick = function()
{
reverse(e);
};
  };
  </script>
 </HEAD>

 <BODY>
  <p id = "press" >
  <h1>one</h1>
<h2>two</h2>
<h3>three</h3>
  </p>
  <input type="button" value="press" />
 </BODY>
</HTML>

------------------------------------------------

为什么 我把 <h1>one</h1>
<h2>two</h2>
<h3>three</h3>
换成<li>one</li>
  <li>two</li>
  <li>three</li>
就能运行,难道<h1>不能作为<p>的子节点?


------解决方案--------------------
h1 h2 h3不能嵌套在p标签里面

是html语意规定~·