gpt4 book ai didi

javascript - 在 div 上调用 .jSignature() 不会更新 div

转载 作者:行者123 更新时间:2023-12-03 07:07:27 25 4
gpt4 key购买 nike

我从 GitHub 获取了此代码:

<script src="path/to/jSignature.min.js"></script>

<script>
$(document).ready(function() {
$("#signature").jSignature()
})
</script>

<div id="signature"></div>

但它不会在实际网页上提取任何内容。我认为需要更多代码,但我不知道从哪里开始。

最佳答案

这是一个最小的工作示例

<!DOCTYPE html>
<html lang="en">
<head>
<lang>
<title>Minimal working jSignature Example</title>
<meta charset="UTF-8">
<!-- Files from the origin -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://willowsystems.github.io/jSignature/js/libs/jSignature.min.js"></script>
<head>
<script>
$(document).ready(function() {
// Initialize jSignature
$("#signature").jSignature();
})
// ripped from the description at their the Github page
function getBase64Sig(){
// get the element where the signature have been put
var $sigdiv = $("#signature");
// get a base64 URL for a SVG picture
var data = $sigdiv.jSignature("getData", "svgbase64");
// build the image...
var i = new Image();
i.src = "data:" + data[0] + "," + data[1];
// and put it somewhere where the sun shines brightly upon it.
$(i).appendTo($("#output"));
}
</script>
<body>
Put your signature here:
<div id="signature"></div>
<button onclick="getBase64Sig()">Get Base64</button>
<div id="output"></div>
</body>
</html>

我希望你能从这里继续下去。

这确实像他们描述的那样简单,只是他们对实际示例的描述对于初学者来说有点缺乏。

关于javascript - 在 div 上调用 .jSignature() 不会更新 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36757148/

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