jQuery dynamic canvas creation, $ctx.getContext is not a function

前端 未结 3 1227
终归单人心
终归单人心 2020-12-23 21:14

When I try to execute this in jQuery I get $ctx.getContext is not a function in firebug.

var $ctx = $( \'\', {width:\'100\', hei         


        
3条回答
  •  甜味超标
    2020-12-23 21:50

    If using excanvas you will need to use the following so it works in IE.

    var canvas = $ctx[0];
    
    if (canvas.getContext == undefined) {
        return G_vmlCanvasManager.initElement(canvas).getContext("2d"); 
    }
    
    return canvas.getContext('2d')
    

提交回复
热议问题