开发者社区 问答 正文

js多选跳转问题

$(".skip-btn").click(function(event){
    $val = $(".second-tag li a.active").text();
    $url = window.location.href;
    window.location.href = 'index.html/tag/' + $val;
});

这是一个标签跳转,单选直接跳转到/tag/$val,多选跳转到/tag/xx+xx+xx,js该如何写?
screenshot

展开
收起
杨冬芳 2016-06-12 14:19:36 1836 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • IT从业
    $(".skip-btn").click(function(event){
        $val = [];
        $(".second-tag li a.active").each(function(){
            $val.push($(this).text());
        });
        
        if($val.length==0) {
            return;
        }
        $url = window.location.href;
        window.location.href = 'index.html/tag/' + $val.join('+');
    });
    2019-07-17 19:33:59 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
问答分类:
问答地址:
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等