【问题标题】:html append square div in 4 directionshtml在4个方向追加方形div
【发布时间】:2016-09-22 00:43:48
【问题描述】:
首先,您将看到正方形数字 1 ,
当您按正方形 1 顶部的 + 时,
方块2会出来,你可以按方块2右边的+,
然后方格 3 就会出来。
我可以这样做吗?或者我该怎么做?
【问题讨论】:
标签:
javascript
jquery
html
【解决方案3】:
是的,你可以做到,你会在下面的 Jsfiddle 中找到我的解决方案
jQuery(document).ready(function() {
jQuery('.plus').on('click', function() {
if(jQuery('.one').is(":visible") != true){
jQuery('.one').removeClass('hide');
}else {
jQuery('.two').removeClass('hide');
}
});
});
.box {
background: grey;
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
color: white;
font-size: 24px;
font-family: sans-serif;
}
.hide {
display: none !important;
}
.plus {
display: block;
text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div class="box one hide">2</div>
</td>
<td><a href="javascript:;" class="plus one hide">+</a></td>
<td>
<div class="box two hide">3</div>
</td>
</tr>
<tr>
<td><a href="javascript:;" class="plus">+</a>
<div class="box">1</div>
</td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>