V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
acpp
V2EX  ›  问与答

v2还有没睡觉的前端么朋友么,来帮下忙

  •  
  •   acpp · 2012-10-30 01:23:28 +08:00 · 2608 次点击
    这是一个创建于 4219 天前的主题,其中的信息可能已经有所发展或是发生改变。
    怎么能用最短的一段代码获取到当前页面的路径

    <div class="show-tabs">
    <a name="brief_tab"></a>
    <ul>
    <li class="selected">商品简介</li>
    <li class="other"><a href="#records_tab">购买记录</a></li>
    <li class="other"><a href="#comment_tab">客户评价 </a><span>()</span></li>
    <li class="other"><a href="#consult_tab">商品咨询 </a><span>()</span></li>
    <li class="other"><a href="#shouhou_tab">售后服务</a></li>
    <li class="other"><a href="#pay_tab">支付方式</a></li>
    </ul>
    </div>

    现在这段代码,#号前,在点击的时候,直接获取到的是首页的路径,我像在#前加段获取当前页面地址的js 然后获取到当前页面地址
    2 条回复    1970-01-01 08:00:00 +08:00
    hzlzh
        1
    hzlzh  
       2012-10-30 01:45:30 +08:00
    刚好正要睡,下面这样功能?
    $('a[href^="#"]').each(function(index){
    $(this).attr('href',location.href + $(this).attr('href'));
    });
    acpp
        2
    acpp  
    OP
       2012-10-30 01:55:39 +08:00
    @hzlzh 谢谢啊,我试试
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1812 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 16:23 · PVG 00:23 · LAX 09:23 · JFK 12:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.