How to use getContext() in jQuery

How to use getContext() in jQuery

I'm trying to use&nbsp;getContext('2d');&nbsp;in jQuery. I have seen&nbsp;<a href="https://stackoverflow.com/questions/2925130/jquery-equivalent-of-getting-the-context-of-a-canvas" target="_blank">this question</a>, 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&nbsp;&lt;script src='<a href="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'&gt;&lt;/script&gt;" target="_blank">https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'&gt;&lt;/script&gt;</a>&nbsp;in the head, but using a different&nbsp;&lt;script&gt;&nbsp;tag. Here is all my code:

I'm trying to use getContext('2d'); in 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. Here is all my code:

var c = $('.canvas');
var ctx = $(c)[0].getContext('2d');

window.onload = function() { $c.width(500); $c.height(250); $c.css({'background-color': '#e2e2e2', 'margin': '0 auto', 'display': 'block'}); } <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!

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

jQuery ajax get request method example

### jQuery Ajax Get Request Method Example This article is originally published at [https://www.tutsmake.com/jquery-api-ajax-get-method-example/](https://www.tutsmake.com/jquery-api-ajax-get-method-example/...

jQuery Crash Course: jQuery Tutorial Step by Step

jQuery Crash Course: jQuery Tutorial Step by Step