Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6106331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:04:05+00:00 2026-05-23T14:04:05+00:00

I have following html menu: <ul> <li><a href=About/about-page.html></a></li> <li><a href=Services/services-page.html></a></li> </ul> How can I

  • 0

I have following html menu:

<ul>
    <li><a href="About/about-page.html"></a></li>
    <li><a href="Services/services-page.html"></a></li>
</ul>

How can I with jQuery check if current URL have string of for example ‘About/’ (as ‘about’ any case + ‘ / ‘ ) in it?

Where ‘About/’ can be any word.

Basically run through my menu and check if there’s a string same as the part of the URL.
For example that:

  • http://www.website.com/about/ = true
  • http://www.website.com/about/something.html = true
  • http://www.website.com/about-something.html = false
  • http://www.website.com/services/about.html = false

Any help much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:04:05+00:00Added an answer on May 23, 2026 at 2:04 pm

    Assuming a variable currentURL contains the string you wish to check, and you don’t care whether it’s got an uppercase ‘A’ or not:

    if(currentURL.toLowerCase().indexOf("about") != -1) {
       //Contains 'about'
    }
    

    If you want to use the URL of the current page:

    var currentURL = window.location.href;
    

    Based on your comment, I think you are trying to apply a class to any a element in your list with the word “about” in the href attribute. In that case:

    $("li > a").filter(function() {
       if($(this).attr("href").toLowerCase().indexOf("about") != -1) return true;
       return false;
    }).addClass("newClass");
    

    Update (based on your comments)

    You can wrap this in a function that takes the keyword to look for, and the name of the class to add, then call it whenever necessary:

    function applyClass(keyword, class) {
        $("li > a").filter(function() {
           if($(this).attr("href").toLowerCase().indexOf(keyword) != -1) return true;
           return false;
        }).addClass(class);
    }
    applyClass('service', 'newClass'); //Or for example applyClass('about', 'newClass');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html: <!-- MainMenu --> <ul class=main-menu> <li><a href=About/xxxxx>About</a></li> <li><a href=Services/xxxxx>Services</a></li>
I have the following html <div id=menu> <ul class=horizMenu> <li id=active><a href=# id=current>About</a></li> <li><a
I have following HTML menu: <ul> <li><a href=index.html>Index Page</a></li> <li><a href=#some-page>Some Page</a></li> </ul> Let
I have the following HTML: <div class=menu> <a class=main-nav-item href=home>home</a> <a class=main-nav-item-current href=business>business</a> <a
We have the following HTML: <option value=4def1b88a1247><a href=link>Text</a></option> When using jquery-ui select menu, the
I have the following HTML: <header> <nav> <ul> <li id=menu-item-1><a href=javascript:void(0)>Lien 1</a></li> <li id=menu-item-2><a
I have HTML menu structure. With the following: <div id=footer-menu> <ul> <li><a id=menu-1 href=site.com/1></a></li>
I have created a jquery dropdown menu with the following HTML: <dl class=dropdown> <dt><a
Suppose I have following html page. <html> <head> <link type=text/css rel=Stylesheet href=css/some.css /> </head>
I have the following HTML page: <html> <head> <script type=text/javascript src=JavaScript/Menu.js></script> </head> <body> <ul>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.