php - Make parent name active in the menu when I'm in its child page -


i have recursive function:

function recursive($arrays, $out) { if (is_array($arrays)){      //$out .= "<ul>";      foreach($arrays $parent => $data) {          //if parent empty          if ($parent === '') {              $out = recursive($data, $out);              continue;          }           $out .= "<li>";          if (is_array($data)){              $out .= ' <a href="#" class="dropdown-toggle active" data-toggle="dropdown">';$out .= $parent;          }          else          { $directory =explode("@", $parent)[0];$paname = explode("@", $parent[1]; $link = 'http://127.0.0.1/ocos/index.php?module='.$directory.'/'.$paname;              $out .= '<a href="'.$link.'">'; $out .= $data;           }           if (is_array($data)){               $out .= '<b class="caret"></b></a>';          }          else          {              $out .= "</a>";          }          if (is_array($data)){             $out .= "<ul class='dropdown-menu'>";             $out = recursive($data, $out);             $out .= "</ul></li>";          }          else          {          $out .= "</li>";           }      }     }  

return $out; }

in menu bar have dropdown menu parent calledoperation , child page called aro , aro have child page called aro document list wanna when i'm in aro document list make parent operation active green color make user know in part of menu in. thank u in advance

i think you're making complicated. below need? when click on a,b or c parent green background.

$("li").on("click", function() {    var grandparent = $(this).parent("ul").parent("li");    if (grandparent.length > 0) {      grandparent.css("background", "green");    }  });
ul {    padding: 0;    list-style: none;    background: white;  }    li {    cursor: pointer;  }    .operations {    display: flex;  }    .operations li {    width: 25px;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <ul class="operations">    <li>1</li>    <li>2</li>    <li>3      <ul class="aro">        <li>a</li>        <li>b</li>        <li>c</li>      </ul>    </li>  </ul>


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -