如何使用javascript截取div的截图? [英] How to take screenshot of a div using javascript?
本文介绍了如何使用javascript截取div的截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
比如说我有一个带图像源的div
Say for example i have a div with image source
<div>
<p class="row">With custom CSS</p>
<img src="/images/midhun.jpg">
</div>
点击按钮我需要在另一个div中打开此图像屏幕
On button click i need to open this image screen shot in another div
你能说出采取该图像截屏的步骤吗?
Can you tell the steps to take the screen shot of that image
推荐答案
假设,你想要的在其他 div
中显示图像
。
Assuming, you want to show the image
in other div
.
HTML :
<div id="main">
<img src="https://lh5.googleusercontent.com/-XOGfvAHr7HQ/UvoUItkZMZI/AAAAAAAAHJk/IJz5JcUB9dw/w520-h274-no/scopes_in_directives.png" />
</div>
<div id="copy">
</div>
<button id="myButton">Click</button>
Javascript:
Javascript:
$('#myButton').on('click', function() {
$('#copy').html($('#main').html());
});
演示: https://jsfiddle.net/tusharj/uapf99nt/
这篇关于如何使用javascript截取div的截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文