简体   繁体   English

Bootstrap 4 下拉菜单无法正常工作

[英]Bootstrap 4 dropdown not working properly

Learning Bootstrap 4 and the following are the simple codes.学习 Bootstrap 4 及以下是简单的代码。 The dropdown is not dropping down or working.下拉菜单没有下降或工作。 When I tried with the select it's working.当我尝试使用select时,它正在工作。 What are the ways to do things right?有哪些正确的方法?

echo '<div class="dropdown">';
echo '<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">'.strtoupper($field).'</button>';
           echo '<div class="dropdown-menu">'; 
           for($i = date('Y'); $i >= 1900; $i--) {
                  echo "<a class='dropdown-item' href='#'>$i</a>";
           }
echo '</div></div>';

Try this:尝试这个:

   echo "<ul>";
  for($i = date('Y'); $i >= 1900; $i--) {
     echo "<li><a class='dropdown-item' href='#'>$i</a></li>";
  }
  echo "</ul>";

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

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