首先,为这个凌乱的头衔辩护,我无法想出更好的一个。您将在代码中更好地理解问题。当我点击私立大学时,我可以激活该按钮,但我想激活按钮学习机会。感谢。
<li class="dropdown <?php if(basename($_SERVER['SCRIPT_NAME']) == 'study-opportunity.php'){echo 'active'; }else { echo ''; } ?>">
<a href="study-opportunity.php" role="button" aria-expanded="false">Study Opportunity<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'universitetet-me-konkurim.php'){echo 'active'; }else { echo ''; } ?>"><a href="universitetet-me-konkurim.php">Universitetet me Konkurim</a></li>
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'private-university.php'){echo 'active'; }else { echo ''; } ?>"><a href="private-university.php">Private University</a></li>
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'studime-jashte-vendit.php'){echo 'active'; }else { echo ''; } ?>"><a href="studime-jashte-vendit.php">Studime Jashte Vendit</a></li>
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'bursa.php'){echo 'active'; }else { echo ''; } ?>"><a href="bursa.php">Bursa Studimi</a></li>
</ul>
</li>
答案 0 :(得分:0)
您还必须检查下拉列表中的所有链接:
<li class="dropdown <?php if(basename($_SERVER['SCRIPT_NAME']) == 'study-opportunity.php' || basename($_SERVER['SCRIPT_NAME']) == 'universitetet-me-konkurim.php' || basename($_SERVER['SCRIPT_NAME']) == 'private-university.php' || basename($_SERVER['SCRIPT_NAME']) == 'studime-jashte-vendit.php' || basename($_SERVER['SCRIPT_NAME']) == 'bursa.php'){echo 'active'; }else { echo ''; } ?>">
<a href="study-opportunity.php" role="button" aria-expanded="false">Study Opportunity<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'universitetet-me-konkurim.php'){echo 'active'; }else { echo ''; } ?>"><a href="universitetet-me-konkurim.php">Universitetet me Konkurim</a></li>
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'private-university.php'){echo 'active'; }else { echo ''; } ?>"><a href="private-university.php">Private University</a></li>
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'studime-jashte-vendit.php'){echo 'active'; }else { echo ''; } ?>"><a href="studime-jashte-vendit.php">Studime Jashte Vendit</a></li>
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'bursa.php'){echo 'active'; }else { echo ''; } ?>"><a href="bursa.php">Bursa Studimi</a></li>
</ul>
</li>