简体   繁体   中英

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.

Their code modifies the canvas and adds two text values. I need to access these two values in my javascript code and read them.

Is this possible? Searching in Google is giving so few answers that I am worried it is not.

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 :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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