这是我的第一篇文章。 任何人都可以告诉我为什么这不会创建网格?提示符正常,控制台中没有错误 链接 - > http://codepen.io/Bairdy/pen/ALBzgJ
function grid_reset() {
$(".grid").empty();
new_grid();
};
function new_grid($grid_size) {
var $grid_size = prompt("How many squares would you like?");
var size = 500 / $grid_size;
for (var i = 0; i < all_squares; i++) {
$(".grid").append('<div class="square"></div>');
}
$(".square").width(size);
$(".square").height(size);
};
答案 0 :(得分:0)
你有没有想过这个?
function new_grid() {
var $grid_count = prompt("How many squares would you like?");
var size = 500 / $grid_count;
for (var i = 0; i < $grid_count; i++) {
$(".grid").append('<div class="square"></div>');
}
$(".square").width(size);
$(".square").height(size);
};