<html>
<body>
<p>单击按钮可创建一个 IMG 元素。</p>
<button onclick="myFunction()">试一试</button>
<br><br>
<script>
function myFunction() {
var x = document.createElement("IMG");
x.setAttribute("src", "/i/photo/tulip.jpg");
x.setAttribute("width", "300");
x.setAttribute("height", "300");
x.setAttribute("alt", "Tulip");
document.body.appendChild(x);
}
</script>
</body>
</html>