如何将HTML String 转换为 dom 元素
2015-12-20
展开全部
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id="show">2333</div>
<script>
var str = '<div class="d1">123</div>';
document.getElementById('show').innerHTML += str;
var div = document.createElement('div');
div.className = "d2";
div.innerHTML = "4444";
document.getElementById('show').appendChild(div);
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询