css 保持当前菜单项高亮显示

rvpgvaaj  于 2022-12-15  发布在  其他
关注(0)|答案(1)|浏览(225)

我的页面上有一个菜单设置,可以将项目加载到iframe中。它们是自定义Map,可以替换默认的GoogleMap。我的问题是如何让当前显示项目的菜单项保持高亮显示?

<div id="right_col" class="clearfix">

            <ul>
                <li><a href="copperwood.html" target="iframe_map">Copperwood</a></li>
                <li><a href="canyoncrest.html" target="iframe_map">Canyon Crest/The Canyons</a></li>
                <li><a href="riverstone.html" target="iframe_map">Riverstone</a></li>
                <li><a href="garrystation.html" target="iframe_map">Garry Station</a></li>
                <li><a href="legacyridge.html" target="iframe_map">Legacy Ridge</a></li>
                <li><a href="https://maps.google.com/maps/ms?msa=0&amp;msid=217268423195093625679.0004cf68eb14897eb07b4&amp;ie=UTF8&amp;ll=49.69371,-112.868754&amp;spn=0.086835,0.089951&amp;t=m&amp;output=embed" target="iframe_map">Overall Lethbridge</a></li>
            </ul>

        </div>

我的CSS:

#right_col ul{
position: relative;
list-style: none;
top: -17px;
}

#right_col ul a{
text-decoration: none;
color: #000000;
display: block;
padding:10px 10px 10px 15px;
margin: 10px;
background: #eeeeee;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; /* future proofing */
-khtml-border-radius: 10px; /* for old Konqueror browsers */
}

#right_col ul a:hover{
background: #e9b900;
text-decoration: none;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; /* future proofing */
-khtml-border-radius: 10px; /* for old Konqueror browsers */
}
qltillow

qltillow1#

1.为第一个li标记指定一个类,例如li class="active"..
2.转到你的css,然后执行以下操作:

.active{
background-color:red; // example
}

3.那就打开

script `type="text/javascript"`

$('li a').click(function()
{
  $('li').removeClass('active');
  $(this).parent().addClass('active');
});

</script>

相关问题