手机
当前位置:查字典教程网 >网页设计 >脚本HTML教程 >创建HTML5新标签(IE6~8)
创建HTML5新标签(IE6~8)
摘要:document.createelement能创建html5的新标签,但动态创建尤其是元素时,还是用innerhtml比较适合。不过ie的i...

  document.createelement能创建html5的新标签,但动态创建尤其是元素时,还是用innerhtml比较适合。不过ie的innerhtml存在大量的问题,style,link ,script就需要特殊方法去生成。这种方法又将用于我们html5的新元素的创建!见下面例子:

<!doctype html>
<html>
  <head>
    <title>动态创建html5元素 by 司徒正美</title>
    
    <script>
  
      var div = document.createelement("div");

      div.innerhtml = "<section>section</section>";

      alert( div.innerhtml ); // "section</section>" in ie6~ie8

           
    </script>
</head>
<body>
动态创建html5元素 by 司徒正美
</body>
</html>

代码二

<!doctype html>

<html>
  <head>
    <title>动态创建html5元素 by 司徒正美</title>
    
    <script>
  
      var div = document.createelement("div");
        div.innerhtml = "fixie<div>" +"<section>section</section>" +"</div>";
        alert(div.innerhtml );

        alert( div.lastchild.innerhtml );

           
    </script>
</head>
<body>
动态创建html5元素 by 司徒正美
</body>
</html>

【创建HTML5新标签(IE6~8)】相关文章:

xhtml的结构标签

初学者HTML的表格标记详细讲解

如何在Fireworks 8中创建HTML切片

XHTML框架结构标签

XHTML基础教程(一)

HTML表格的标题

HTML网页META标签内容写作

HTML 4.0 语法排版标签

HTML 4.0 语法框架标签

DD DT DL标签使用示例

精品推荐
分类导航