简体   繁体   English

使用jQuery访问画布上的内容

[英]Access content on canvas with jQuery

I have very little experience with canvas but I am attempting to access some code written by someone else. 我对画布的经验很少,但是我尝试访问其他人编写的一些代码。 I am used to working with the DOM in HTML so I am finding the canvas very unusual. 我习惯于使用HTML中的DOM,因此发现画布非常不寻常。

Their code modifies the canvas and adds two text values. 他们的代码修改了画布并添加了两个文本值。 I need to access these two values in my javascript code and read them. 我需要在我的JavaScript代码中访问这两个值并阅读它们。

Is this possible? 这可能吗? Searching in Google is giving so few answers that I am worried it is not. 在Google中搜索的答案很少,我担心不是这样。

Edit: Before anyone asks, the only part I have understood so far is the following: 编辑:在任何人问之前,到目前为止我唯一了解的部分是:

$("#canvas")[0].getContext('2d');

I am not sure where to go from here. 我不确定从这里去哪里。 Many thanks 非常感谢

You can use jquery get() method as follows : 您可以使用jquery get()方法,如下所示:

var canvas = $("#canvas").get(0);
var twoDContext = canvas.getContext('2d');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM