首页 > 编程 > HTML > 正文

创建HTML5新标签!(IE6~8)

2020-03-24 15:54:17
字体:
来源:转载
供稿:网友

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>

&

6080电影网[www.aikan.tv/special/6080dianyingwang/]nbsp; <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>

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表