CDN

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>

Code

<script>
$(":button").click(function () {
    html2canvas($("#wrap")[0], {
        onrendered: function (canvas) {
            var $div = $("#output");
            $div.empty();
            $("<img />", { src: canvas.toDataURL("image/png") }).appendTo($div);
            //$("<img />", { src: img }).appendTo($div);
        }
    });
});
</script>

下面我在CodePen有做一個範例,可參考。