dqotv26286 2017-09-05 12:43
浏览 378
已采纳

添加查看更多按钮

I have this section created by bootstrap SQLserver and php...

Is there any way to display just a little of it and give the view more button option to display the whole result?

enter image description here

There are like 10 Decks, and I want e.g to sidplay just 2 and when user clicks View More to display all of them.

This is my php code for that result.

<div class="vertical-wrapper">
<?php 
for($i=0;$i<count($decks);$i++){
   $deck_name = $decks[$i]['name'];
   $deck_desc = $decks[$i]['description'];                                        
   $deck_img_link = $json['deckplans'][$i]['images'][0]['href'];
  echo "<img class='bd-imagelink-157 bd-own-margins bd-imagestyles' src='$deck_img_link'><p class='bd-textblock-779 bd-content-element'>$deck_name</p>";
   echo $deck_desc;
 }
?>
</div>

I tried to put the bootstrap add more button but is displayed in the end of the section,after all content is loaded, and is pointless

  • 写回答

1条回答 默认 最新

  • dounue6984 2017-09-05 13:22
    关注

    The following example demonstrates how you might reveal additional hidden items one at a time. You will need to use the jQuery JavaScript library for this to work.

    $('#viewmore').on('click', function(){
        $('.item:hidden').show();
    })
    .hidden {
      display: none;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div class="item">
    ITEM 1
    </div>
    <div class="item hidden">
    ITEM 2
    </div>
    <div class="item hidden">
    ITEM 3
    </div>
    <div class="item hidden">
    ITEM 4
    </div>
    <button id="viewmore">
    View More
    </button>
    </button>

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件