I have the following working code:
ctx = document.getElementById(\"canvas\").getContext(\'2d\');
Is there any way to re-write it to use
Try:
$("#canvas")[0].getContext('2d');
jQuery exposes the actual DOM element in numeric indexes, where you can perform normal JavaScript/DOM functions.