代码之家  ›  专栏  ›  技术社区  ›  eozzy

从值中移除#(jQuery)

  •  2
  • eozzy  · 技术社区  · 15 年前
    var current = $(this).attr('href');
    alert(current);
    

    3 回复  |  直到 15 年前
        1
  •  4
  •   jAndy    15 年前
    var current = $(this).attr('href').slice(1);
    alert(current);
    
        2
  •  2
  •   James    15 年前

    <a> 元素?

    this.hash.substring(1); // yes, it's that simple...
    
        3
  •  1
  •   jigfox    15 年前

    replace :

    var current = $(this).attr('href').replace('#','');