what is that?

everytime it works, but this time it does not

$(function() {  //jquery doc ready

    world = createWorld(); // box2DWorld  
    ctx = $('#game').getContext('2d'); // 2  
    var canvasElm = $('#game');  


    canvasWidth = parseInt(canvasElm.width);  
    canvasHeight = parseInt(canvasElm.height);  
    initGame(); // 3  
    step(); // 4  
// 5  

What is wrong here? WHy no get context?
and html:


<!--[if IE]><script src="lib/excanvas.js"></script><![endif]-->  
 <!--<script src="libs/prototype-"></script>  -->

 <!-- <script src="//ajax.googleapis.com/ajax/libs/prototype/"></script> -->
 <script type="text/javascript" src="libs/jquery-1.7.1.min.js"></script>
<!-- box2djs -->  
  <script src="libs/Box2dWeb-2.1.a.3.min.js"></script>  

  <script src='js/box2dutils.js'></script>  
  <script src='js/game.js'></script>  

  <canvas id="game" width="600" height="400"></canvas>  

var canvasElm = document.getElementById('game');  
    ctx = canvasElm.getContext('2d'); // 2  

Found out that without jqueyr it works. This does not make sence. What is the differecnec between





When using jQuery, the $('#game') selector selects ALL elements with the game ID and does not give you the actual DOM element to allow you to do this. jQuery exposes the actual DOM elements by numeric index to allow regular DOM/Javascript functions:

var canvasElm = $('#game')[0];

Sorry just looked at the rest of your code and noticed you use the cavasElm for other things as well so you'd be better off using the index in your actual getContext call:

ctx = $('#game')[0].getContext('2d');
var canvasElm = $('#game');


var canvasElm = $('#game');
ctx = canvasElm[0].getContext('2d'); // 2

thanks. now how to not forget this next time :D but at least I will maybe remember this thread :)