哪个库和jquery适合这个代码
which library and jquery suitable for this code?
我有一些代码在html2canvas。在代码中,jquery是合适的,我试图使html2canvas.js文件插入注释,但$符号没有定义。在记事本没有输出结果。如何获取下载pdf&png图像的get结果?
$(document).ready(function() {
var element = $("#html-content-holder"); // global variable
var getCanvas; // global variable
html2canvas(element, {
onrendered: function(canvas) {
getCanvas = canvas;
}
});
var specialElementHandlers = {
'#editor': function(element, renderer) {
return true;
}
};
$("#cmd").on('click', function() {
var imgageData = getCanvas.toDataURL("image/png");
// Now browser starts downloading it instead of just showing it
var newData = imgageData.replace(/^data:image'/png/, "data:application/octet-stream");
$("#cmd").attr("download", "Sample_Pic.png").attr("href", newData);
var doc = new jsPDF();
doc.fromHTML($('#target').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
});
});
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="shot.js"></script>
<script type="text/javascript" src="html2canvas.js"></script>
<link rel="stylesheet" type="text/css" href="shot.css">
</head>
<body>
<div id="html-content-holder" style="background-color: #FFFFFF; width: 500px;
padding-left: 25px; padding-top: 10px;">
<div id="target">
<div id="content">
<h3>Hello, this is mathit app</h3>
<a class="upload">Upload to Formulas</a>
<h2>
This is <b>10th Std Notes</b> <span style="color: red"></span>
</h2>
<p>Study about The polynomial of degree two is called quadratic polynomial and equation corresponding to a quadratic polynomial P(x) is called a quadratic equation in variable x. Thus, P(x) = ax2 + bx + c =0, R is known as the standard form of quadratic
equation. There are two types of quadratic equation. (i) Complete quadratic equation : The equation ax2 + bx + c =0 where a,b,c is not equal to 0. (ii) Pure quadratic equation : An equation in the form of ax2 = 0, a is not equal to 0, b,c is
equal to 0.</p>
</div>
</div>
</div>
<a id="cmd" href="#" class="button">generate PDF</a>
<br/>
</body>
</html>
$符号没有定义,因为您忘记包含jQuery库。将库包含在head标签中。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
这是一个链接到他们的cdn列表
相关文章:
- 如何动态插入jquery代码
- 如何在php变量中嵌入JQuery代码
- 将 jQuery 代码添加到 Index.aspx 页面
- 元素在我的代码中不会.fadeTo.Don'I don’我不知道;s错误的JavaScript、JQuery、H
- jquery代码在Mozilla中有效,但在其他浏览器上无效
- Jquery:代码在rails中的页面加载时未执行
- 您有更好的动态方式来缩短复杂的代码jquery吗
- Don't工作警报代码jQuery
- <script src=“//代码.jquery.com/jquery-1.11.1.min.js”></
- 如何确保我的值已添加并存在,然后运行另一个代码jquery
- 命令代码jquery文件错误
- 解释此代码 jQuery
- 使用 JavaScript 编写 HTML 代码 (jquery)
- 将 Ruby 数组传递给 Ruby on Rails 中 Haml 视图中的 JavaScript 代码 (jquery
- 通过国家代码jquery获取时区
- 什么是错误的这个自动完成代码(JQuery-UI自动完成)
- 抓取国家从谷歌地理代码jquery
- 检查列表中的元素是否有来自变量的SRC,然后运行代码- jQuery / Javascript
- 在附加代码jquery中包含附加内容
- 将变量php问题化为代码jquery