【发布时间】:2012-04-08 21:25:33
【问题描述】:
我正在使用 JQuery 构建带有表格单元格的菜单。现在这个 JQuery 是一个测试,如果我离开第一个单元格并且我没有进入第二个单元格,它应该只提醒“你好”。当我从第一个牢房进入第二个牢房时,它仍然会触发。我发现表的行之间有一个很小的空间,这导致 JQuery 认为我不在第二个单元格内。这是 JQuery...
$("#layer2_cell1").mouseenter(function() {
$("#storage").data("2", "1");
});
$("#layer2_cell1").mouseleave(function() {
$("#storage").data("2", "0");
});
$("#layer1_cell1").mouseenter(function() {
$("#storage").data("1", "1");
});
$("#layer1_cell1").mouseleave(function() {
$("#storage").data("1", "0");
var test1 = $("#storage").data("2");
if (!(test1 == "1")) {
alert("hello");
}
});
这里是一些html...
<table align="center" cellspacing="0">
<tr>
<td class="leftend" background="images/box_background.jpg">
</td>
<div id="test">
<td id="layer1_cell1" class="layer1" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>Airplanes</b></font>
</td>
</div>
<td id="layer1_cell3" class="layer1" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>Cars</b></font>
</td>
<td id="layer1_cell4" class="layer1" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>Cell Phones</b></font>
</td>
<td id="layer1_cell2" class="layer1" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>Televisions</b></font>
</td>
<td id="layer1_cell5" class="layer1" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>Other</b></font>
</td>
<td class="rightend" background="images/box_background.jpg">
</td>
</tr>
<tr>
<td id="permanentlyhiddencell" class="leftend">
</td>
<td id="layer2_cell1" class="bottomcell" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>Cessna</b></font>
</td>
<td id="layer2_cell2" class="layer2" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>Mercedes Benz</b></font>
</td>
<td id="layer2_cell3" class="layer2" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>LG</b></font>
</td>
<td id="layer2_cell4" class="layer2" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>LG</b></font>
</td>
<td id="layer2_cell5" class="layer2" background="images/box_background.jpg">
<font size="5" color="#01DFD7"><b>Balloons</b></font>
</td>
</tr>
还有 css...
.layer1 {
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 150px;
height:75px;
}
.layer2 {
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 150px;
height:75px;
}
.bottomcell {
border-bottom-left-radius:15px;
border-bottom-right-radius:15px;
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 150px;
height:75px;
}
.rightend {
border-top-right-radius:15px;
border-bottom-right-radius:15px;
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 30px;
height:75px;
}
.leftend {
border-top-left-radius:15px;
border-bottom-left-radius:15px;
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 30px;
height:75px;
}
.layer1 {
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 150px;
height:75px;
}
.layer2 {
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 150px;
height:75px;
}
.bottomcell {
border-bottom-left-radius:15px;
border-bottom-right-radius:15px;
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 150px;
height:75px;
}
.rightend {
border-top-right-radius:15px;
border-bottom-right-radius:15px;
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 30px;
height:75px;
}
.leftend {
border-top-left-radius:15px;
border-bottom-left-radius:15px;
text-align:center;
border-style:solid;
border-color:#01DFD7;
border-style:solid;
border-width:2px;
width: 30px;
height:75px;
}
【问题讨论】:
-
如果没有您的 HTML 或 CSS 部分代码,真的很难分辨!你为什么不把你的代码放在 jsfiddle 中
标签: html jquery html-table menu cell