jQuery equivalent of getting the context of a Canvas

前端 未结 4 1018
情歌与酒
情歌与酒 2020-11-30 00:18

I have the following working code:

ctx = document.getElementById(\"canvas\").getContext(\'2d\');

Is there any way to re-write it to use

4条回答
  •  孤街浪徒
    2020-11-30 00:37

    The script works before it finds "canvas"

     $(document).ready(function() {
       ctx = $("#canvas");
    });
    

提交回复
热议问题