代码示例:(标识:eg_js_dom_change_attribute)
<!DOCTYPE html>
<html>
<body>

<img id="image" src="/static/demo/images/eg_smile.gif">

<script>
document.getElementById("image").src = "/static/demo/images/porsche.jpg";
</script>

<p>原始图像是 eg_smile.gif,但脚本将其更改为 porsche.jpg</p>

</body>
</html>
运行结果: