简体   繁体   English

html 在 4 个方向上附加方形 div

[英]html append square div in 4 directions

First, you will see square number 1 , when you press the + on top of square 1 , square 2 will come out and you can press the + on right of square 2, then square 3 will come out.首先,您会看到第 1 个方块,当您按第 1 个方块顶部的 + 时,会出现第 2 个方块,您可以按第 2 个方块右侧的 +,然后会出现第 3 个方块。

can i do this?我可以这样做吗? or how can i do this?或者我该怎么做?

例子

If you are using jQuery, the click and show methods are what you're after, along the lines of:如果您使用的是 jQuery,则clickshow方法就是您所追求的,如下所示:

$('#one').click(function() {
  $('#two').show();
});
$('#two').click(function() {
  $('#three').show();
});

If you want animation read up on jQuery's animate method.如果你想在 jQuery 的animate方法上阅读动画

Hopefully this helps you get started:希望这可以帮助您入门:

https://jsfiddle.net/qb7mr9b6/1/ https://jsfiddle.net/qb7mr9b6/1/

Here is the working example of what you want, hope you find your solution.这是您想要的工作示例,希望您找到解决方案。

$('.show1').click(function() {
  $('#two').show();
});
$('.show2').click(function() {
  $('#three').show();
});

here is the link for complete working example https://jsfiddle.net/ahmerrkhanzz/7tso9rvs/这是完整工作示例的链接https://jsfiddle.net/ahmerrkhanzz/7tso9rvs/

Yes you can do it, You will find my solution in Jsfiddle in this below是的,你可以做到,你会在下面的 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>&nbsp;</td> <td>&nbsp;</td> </tr> </tbody> </table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM