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 819509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:19:17+00:00 2026-05-15T02:19:17+00:00

I have this wordpress blog that has many pages with subpages that dropdown on

  • 0

I have this wordpress blog that has many pages with subpages that dropdown on hover…. the thing is, I dont want the pages that you hover to link to anything unless they dont have any ul with many anchors inside so just the subpages will have a href different than “#”
So basically Im hacking my way through this with some simple javascript.

   jQuery(document).ready(function(){
   jQuery("#menus li > a").attr("href","#");
 });

This is selecting every a.. and I dont want that… I just want the anchors that are main pages, not subpages… heres the html so maybe you can think of a better way to select this.

Ill explain first

the structure is
an ul with many li that have an anchor inside
if the li also has a ul inside then those are subpages that will appear on hover.
hence the initial anchor should have href=”#”
if there is no ul inside the li then the li a should keep its href.

    <ul id="menus">
      <li>
        <a href="somelink">Main Page</a> //href should be changed to #
        <ul>
            <li>
              <a href="somelink2/">Subpage1</a>
            </li>
            <li>
              <a href="somelink3">Subpage2</a>
            </li>
        </ul>
      </li>
      <li>
        <a href="somelink">MainPage-with-no-subpages</a> //href should not be changed
      </li>
      <li>
        <a href="somelink4">MainPage</a> //href should be changed to #
        <ul>
          <li>
            <a href="somelink5">Subpage</a>
          </li>
          <li>
            <a href="somelink6">Subpage</a>
          </li>
        </ul>
      </li>
</ul>
  • 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-15T02:19:18+00:00Added an answer on May 15, 2026 at 2:19 am

    try

    jQuery(document).ready(function(){
       jQuery("#menus li > ul").siblings('a').attr("href","#");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my WordPress blog to have a page called music. On that page
I have a friend who has code like this in his wordpress files: Blockquote
I have this code in jQuery, that I want to reimplement with the prototype
hopefully a simple question here. I'm running a Wordpress blog that has a bunch
I'm starting a Wordpress Blog that will have adult content on it, so I'll
I have a WordPress blog with numerous URL's I wish to replace from this:
I have a wordpress blog inside the company where I write blogs. I want
I have a wordpress blog. I made a custom page-template that allows users to
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I have a (Wordpress) blog and some of my older posts have a character

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.