下面的代码发送了我想要显示的图像的 URL,其 div ID 为“目标”,到目前为止我只能显示实际的 URL 地址而不是实际的图像。
<script type='text/javascript'>
function updateTarget( img ){
'use strict';
document.getElementById('target').innerHTML = img;
}
</script>
目标div
<div id = 'target'> </div>
任何帮助将不胜感激,因为我正在努力在网上寻找任何有用的示例。
最佳答案
使用这一行:
document.getElementById('target').innerHtml = '<img src="' +img+'"/>';
关于javascript - 使用 GetElementByID 中的 URL 显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50972361/