0
這裏是我的代碼:問題與jQuery和畫布元素
$('#add_shape').click(function() {
var rectHeight = $('#rect_height_input').val();
var WidthOrRadius = $('#widthorradius').val();
$('<canvas>').attr({
id:'canvas'
}).css({
height:function() {
if (rectHeight > 0) {
return rectHeight + 'px';
}
else {
return WidthOrRadius + 'px';
}
},
width:WidthOrRadius + 'px'
})
.appendTo('#work_area');
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = $('#color_list option:selected').val();
ctx.fillRect(0, 0 , WidthOrRadius, rectHeight);
});
此代碼上的jsfiddle(這裏:http://jsfiddle.net/dzejkej/xwg5f/),但不是在我的瀏覽器。我不知道什麼是錯的。有人可以幫忙嗎?
哪個瀏覽器? – czarchaic 2011-12-15 04:18:51
@ czarchaic - firefox最新版本 – dopatraman 2011-12-15 04:31:10