Why canvas doesn't work with jQuery selector?

前端 未结 4 1401
太阳男子
太阳男子 2020-12-29 07:10

I have made simple example of using canvas and then I saw that my code doesn\'t work when I use jQuery selector.

Examples:

Javascript

<
4条回答
  •  一向
    一向 (楼主)
    2020-12-29 07:36

    You can use get function of jquery to retrieve canvas element.

    var canvas = $('#myCanvas').get(0).getContext('2d');
    

提交回复
热议问题