题目
<ul>
<li>1<li>
<li>2<li>
<li>3<li>
</ul>
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var body = document.querySelector('body');
var ul = document.createElement('ul');
body.appendChild(ul);
for (var i = 1; i <= 3; i++) {
ul.innerHTML += '<li>' + i + '</li>'
}
// ul.innerHTML = '<li>1</li><li>2</li><li>3</li>'
</script>
</body>
</html>
运行结果