gpt4 book ai didi

javascript - 将html添加到div而不替换其中的当前内容

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:08:49 30 4
gpt4 key购买 nike

我正在尝试将 dhtml 添加到 ID 为 upload_results 的 div。这应该可以在不替换 div 中的当前内容的情况下工作。

代码:(有趣的部分在底部)

<script language="JavaScript">
function do_show() {
$("#webcamContainer").fadeIn('');
}

webcam.set_hook( 'onComplete', 'my_completion_handler' );

function do_upload() {
upload to server
document.getElementById('upload_results').innerHTML = '<div>Uploading...</div>';
webcam.upload();
}

function my_completion_handler(msg) {
extract URL out of PHP output
if (msg.match(/(http\:\/\/\S+)/)) {
var image_url = RegExp.$1;
show JPEG image in page
$("#upload_results").fadeIn('');
//document.getElementById('upload_results').innerHTML = '<a target="_blank" href="'+image_url+'"><img style="border:#ccc 5px solid;" src="'+image_url+'" width="100px"></a>';// I think here should be something changed
$('#upload_results').append('<a target="_blank" href="'+image_url+'"><img style="border:#ccc 5px solid;" src="'+image_url+'" width="100px"></a>');
reset camera for another shot
webcam.reset();
}
else alert("PHP Error: " + msg);
}
</script>


<div id="upload_results" class="video_header" style="display:none;"></div><!--add data here , without replace current content in div-->

最佳答案

关于javascript - 将html添加到div而不替换其中的当前内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14298989/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com