导航栏高亮

admin 2021-06-09 14:01:57 543浏览 0评论
<script>
$(function(){
    var surl = location.href;
    var surl2 = $(".place a:eq(1)").attr("href");
    $("#nav ul li a").each(function() {
        if ($(this).attr("href")==surl || $(this).attr("href")==surl2) $(this).parent().addClass("on")
    });
});
</script>


<script type="text/javascript">
$(".nav li a").each(function () { if ($(this).attr("href") == $(".place a:eq(0)").attr("href") || $(this).attr("href") == location.href){$(this).parent("li").addClass("ons"); $(this).parents("li").addClass("ons") } });
</script>


<script>

$(document).ready(function() {
    var s = document.location;
    $(".pc-nav a").each(function() {
        if (this.href == s.toString().split("#")[0]) {
            console.log(this.href);
            $(".pc-nav div").removeClass('active');
            $(this).parent("div").addClass("active");
            $(this).parent().parent().parent("div").addClass("active");
            $(".news-list-btn a:eq(0)").addClass('active');
            return false;
        }
    });

    $(".news-list-btn a").each(function() {
        if (this.href == s.toString().split("#")[0]) {
            console.log(this.href);
            return false;
        }
    });


});
</script>


没有更早的文章了...
0条评论