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

Viewed 36953

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

var $ctx = $( '<canvas />', {width:'100', height:'100'} )
$widget.append($ctx)                                     
$ctx.getContext('2d')                                    

Any idea why I get this error? How do I dynamically create and initialize a canvas element?

3 Answers
Related