下面是代碼:爲什麼canvas元素不能綁定事件?
$('#insert_text').click(function(){
var drawing_plate= $("#Drawing_Plate")[0];
context = drawing_plate.getContext('2d');
drawing_plate.bind('touchstart',insert_the_text);
});
我選擇canvas元素,在分配給drawing_plate。但鉻抱怨
Uncaught TypeError: Object #<HTMLCanvasElement> has no method 'bind
但drawing_plate確實是一個jQuery對象,爲什麼沒有擁有方法: .bind()
...?
更新:請給出解釋。
你忘了jQuery的'$';) – Christoph