I'm trying to use getContext('2d');
using jQuery. I have seen this question,
but it doesn't seem to work. It could possibly be from updates, since the question was asked near 9 years ago. I am adding <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
in the head, but using a different <script>
tag for my javascript (shouldn't be a problem). Here is all of my code:
var c = $('.canvas');
var ctx = $(c)[0].getContext('2d');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<canvas id='canvas'>You're browser does not support the requirements to play this game. Update your browser or use a different browser</canvas>
I'm using Google and checking the console through F12, and it says -
Uncaught TypeError: Cannot read property 'getContext' of undefined
Any help is appreciated! Thanks!