I'm very new to JS with HTML5, and I cannot get a very basic piece of code to work. I have made the canvas, appended it to the body, and tried to write text, but nothing shows up.
<!doctype html>
<html lang="en">
<head>
<meta charset='utf-8'>
<title>Test Game</title>
</head>
<body>
<script type="text/javascript">
var CANVAS_WIDTH=480;
var CANVAS_HEIGHT=320;
var canvasElement=$("<canvas width='"+ CANVAS_WIDTH +"'height='"+CANVAS_HEIGHT+"'></canvas>");
var canvas = canvasElement.get(0).getContext("2d");
canvasElement.appendTo('body');
</script>
<script type="text/javascript">
var FPS = 30;
setInterval(function(){
update();
draw();
},1000/FPS);
function update(){
}
function draw(){
canvas.fillStyle = "#000";//Sets colour to black
canvas.fillText("Sup Bro!",50,50);
}
</script>
</body>
</html>