在django模板中向li添加class active

时间:2014-10-19 10:38:11

标签: jquery html css django

base.html文件

<ul class="" id="main-menu" style="">


<li class="root-level has-sub activeroot-level cbs0">
        <a href="#" class=""><i class="entypo-globe "></i><span>CBS</span></a>


    <ul>
        <li>
            <a href="/cbs/cbs1/" class="cbs1"><i class="entypo-lamp "></i><span>Initiative and Decision Making</span></a>
        </li>

        <li>
            <a href="/cbs/cbs2/"><i class="entypo-publish cbs2"></i><span>Analyzing And Problem Solving</span></a>
        </li>

        <li>
            <a href="/cbs/cbs3/"><i class="entypo-search"></i><span>Customer Focus</span></a>
        </li>

        <li>
            <a href="/cbs/cbs4/"><i class="entypo-bookmarks"></i><span>Achieve Business Results</span></a>
        </li>

        <li>
            <a href="/cbs/cbs5/"><i class="entypo-feather"></i><span>Flexibility</span></a>
        </li>

        <li>
            <a href="/cbs/cbs6/"><i class="entypo-shuffle"></i><span>Leading & Engaging</span></a>
        </li>

        <li>
            <a href="/cbs/cbs7/"><i class="entypo-users"></i><span>Teamwork</span></a>
        </li>

        <li>
            <a href="/cbs/cbs8/"><i class="entypo-sound"></i><span>Communication</span></a>
        </li>

        </ul>

</li>

<li class="root-level has-sub std0">
        <a href="#"><i class="entypo-globe "></i><span>SELECT STANDARD WORKS</span></a>


    <ul>
        <li>
            <a href="/cbs/sw1/"><i class="entypo-lamp"></i><span>Initiative and Decision Making</span></a>
        </li>

        <li>
            <a href="/cbs/sw2/"><i class="entypo-publish"></i><span>Analyzing And Problem Solving</span></a>
        </li>

        <li>
            <a href="/cbs/sw3/"><i class="entypo-search"></i><span>Customer Focus</span></a>
        </li>

        <li>
            <a href="/cbs/sw4/"><i class="entypo-bookmarks"></i><span>Achieve Business Results</span></a>
        </li>

        <li>
            <a href="/cbs/sw5/"><i class="entypo-feather"></i><span>Flexibility</span></a>
        </li>

        <li>
            <a href="/cbs/sw6/"><i class="entypo-shuffle"></i><span>Leading & Engaging</span></a>
        </li>

        <li>
            <a href="/cbs/sw7/"><i class="entypo-users"></i><span>Teamwork</span></a>
        </li>

        <li>
            <a href="/cbs/sw8/"><i class="entypo-sound"></i><span>Communication</span></a>
        </li>

        </ul>

</li>
</ul>

我希望在特定页面中将css类添加到li 与网址关联的所有其他模板都从base.html扩展

如果我点击SELECT STANDARD WORKS的主动和决策链接,那么该活动类应该被添加到SELECT STANDARD WORKS li

我尝试过使用jquery,但可能因为页面重新加载而没有将类添加到li中。

这些所有菜单,即li都在基本文件中,并且iam将其扩展到其他模板。所以,我点击它应该活跃。

请指导我

0 个答案:

没有答案