You should use the <canvas id='mycanvas' width='300' height='300' />
element and draw your line like this:
function drawShape(){
// get the canvas element using the DOM
var canvas = document.getElementById('mycanvas');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
// Stroked triangle
ctx.beginPath();
ctx.moveTo(125,125);
ctx.lineTo(125,45);
ctx.lineTo(45,125);
ctx.closePath();
ctx.stroke();
}
}
By adding a timeout and clearing your 2D-Context and afterwards creating it new, you can animate your line
This is a very good tutorial for canvas manipulation.