zoukankan      html  css  js  c++  java
  • 导航点击字体变色

    1、CSS

     .active {
                color: #ff5837;
            }
    

    2、js

    $(".header ul li a").each(function(){
    $this = $(this);
    if($this[0].href==String(window.location)){ 
    $(".header ul li a").removeClass("active");
    $this.addClass("active"); 
    } 
    });
    

    3、方法2

     

    var urlstr = location.href;
    			var urlstatus = false;
    			$("#navigate a").each(function() {
    				if ((urlstr + '/').indexOf($(this).attr('href')) > -1 && $(this).attr('href') != '') {
    					$(this).addClass('active');
    					urlstatus = true;
    				} else {
    					$(this).removeClass('active');
    				}
    			});
    			if (!urlstatus) {
    				$("#navigate a").eq(0).addClass('active');
    			}
    

      

  • 相关阅读:
    11.MySQL
    10、设计模式
    9
    8
    7
    6
    5
    4
    3
    2
  • 原文地址:https://www.cnblogs.com/qing1304197382/p/7273485.html
Copyright © 2011-2022 走看看