Using the JavaScript library to capture the content on screen
Firstly, the html element will be converted into canvas.
<script src="./html2canvas.js"></script>
<script src="./html2canvas.svg.js"></script>
$('#btn').click(function(){
html2canvas($('#img'), {
onrendered: function(canvas) {
var myImage = canvas.toDataURL("image/png");
window.open(myImage);
document.body.appendChild(canvas);
},
background: '#000000',
allowTaint: true,
useCORS: true
});
})