level 1
起个名真心难20
楼主
<script type="text/javascript" language="javascript">
$(function() {
//背景格行
var row = 17;
//背景格列
var col = 14;
//创建内容表格
$("#start").click(function(){
var classNum = $(this).attr("class");
if(classNum == 1){
//创建背景格
createGrid(row,col);
$(this).attr("class", "2");
}
});
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////这里如果用$("#box").click()可以运行,用$("td").click()就什么效果都没有//////////////////////////////////
$("td").click(function() {
alert(1);
});
//创建背景格
function createGrid(row, col) {
var otr = {};
var otable = $("<table id='boxTable'></table>");
for ( var i = 0; i < row; i++) {
otr[i] = $("<tr id='boxTr'></tr>");
$(otable).append(otr[i]);
for ( var j = 0; j < col; j++) {
//td的class值不同,表示意思也不同 1:空 2:数字 3:有雷
otr[i].append($("<td id='boxTd' class='1' style='width: 18px; height: 18px; border: 1px solid red'></td>"));
}
}
$("#box").append(otable);
}
});
</script>
</head>
<body>
<div id="home">
<div id="dargs"></div>
<div id="titles">
<input type="button" id="start" class="1" value="start"/>
</div>
<div id="box">
</div>
</div>
</body>
2018年02月11日 05点02分
1
$(function() {
//背景格行
var row = 17;
//背景格列
var col = 14;
//创建内容表格
$("#start").click(function(){
var classNum = $(this).attr("class");
if(classNum == 1){
//创建背景格
createGrid(row,col);
$(this).attr("class", "2");
}
});
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////这里如果用$("#box").click()可以运行,用$("td").click()就什么效果都没有//////////////////////////////////
$("td").click(function() {
alert(1);
});
//创建背景格
function createGrid(row, col) {
var otr = {};
var otable = $("<table id='boxTable'></table>");
for ( var i = 0; i < row; i++) {
otr[i] = $("<tr id='boxTr'></tr>");
$(otable).append(otr[i]);
for ( var j = 0; j < col; j++) {
//td的class值不同,表示意思也不同 1:空 2:数字 3:有雷
otr[i].append($("<td id='boxTd' class='1' style='width: 18px; height: 18px; border: 1px solid red'></td>"));
}
}
$("#box").append(otable);
}
});
</script>
</head>
<body>
<div id="home">
<div id="dargs"></div>
<div id="titles">
<input type="button" id="start" class="1" value="start"/>
</div>
<div id="box">
</div>
</div>
</body>