javascript canvas document.getElementByClassName();

时间:2016-12-07 01:57:18

标签: javascript canvas

我试图将画布导出到png但是我不确定当作为类调用画布时我得到正确的返回:

var canvas = document.getElementsByClassName('filemanager');
canvas.setAttribute('crossOrigin', 'anonymous');
function download() {var dt = canvas.toDataURL();
this.href = dt; //this may not work in the future..}document.getElementById('download').addEventListener('click', download, false);

在html中我有:<a id="download" download="YourFileName.jpg">Download as image</a> 我在某处读到了如何在调用函数时没有得到相同的期望回报,document.getElementById()document.getElementsByClassName()的回报是什么不同?

0 个答案:

没有答案