JQ - 解决 JQ中 carvas.getContext('2d') 报错 canvas.getContext is not a function


在JQ中 carvas.getContext('2d'),报错 Uncaught TypeError: canvas.getContext is not a function

var canvas = $('canvas');
var context = canvas.getContext('2d');
// 改为
var canvas = $('canvas');
var context = canvas.get(0).getContext('2d');