jQuery / Javascript - 如果当前网址包含/ foo /显示/隐藏ID [英] jQuery / Javascript - Show / hide ID if current url contains /foo/

查看:66
本文介绍了jQuery / Javascript - 如果当前网址包含/ foo /显示/隐藏ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用jQuery,我正在寻找一种方法来隐藏url是否包含/ blah /。

I am using jQuery currently and I am looking for a way to hide if the url contains /blah/.

预先感谢您的帮助。我是一个js Noob并且知道它可以用正则表达式完成,但现在没有时间学习这个。我有一个我需要见面的截止日期!

Thanks in advance for your help. I am a js Noob and know it can be accomplished with regex somehow but don't have the time to learn this right now. I have a deadline I need to meet!

谢谢,
杰克

推荐答案

我认为如果URL包含该部分,他想要隐藏元素。

I think he wants to hide an element if the URL contains that part.

if (/\/blah\//.test(window.location)) {
    $('#element').hide();
}

这篇关于jQuery / Javascript - 如果当前网址包含/ foo /显示/隐藏ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆