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

  • SEARCH
  • Home
  • 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 8672355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:11:00+00:00 2026-06-12T19:11:00+00:00

I am currently making a menu and because the menu is an oddshape with

  • 0

I am currently making a menu and because the menu is an oddshape with a glow around the edge I need to put a blank block over the top to hide the unwanted glow on the overlap. I am creating this using the :after selector on the li tags for the menu and the code to do so works fine.

My problem however is that I can only make it apply to none or all of the menu items at once by toggling the display attribute, what I want however is for the :after selector to only be applied to the current list item.

Each list item has a unique id but I can’t seem to work out how to use the :after selector on a specific list item within jquery.

Thanks in advance for any help. Sorry if this is unclear.

HTML Code

<ul id="menu">
    <li id="0">link 1</li>
<li id="1">link 2</li>
<li id="2">link 3</li>
</ul>

CSS for the list item

#menu li{
float:left;
margin:0 20px 0 0;
height:87px;
z-index:1;
position:relative;
background: #f8f8f8;
cursor:pointer;
border:1px solid #CCC;
border-bottom:none;
}

#menu li:after{
display:none;
content: '';
position: absolute;
top: 0;
bottom: -5px;
left: 0;
width: 291px;
height:10px;
margin-top:109px;
background: #f8f8f8;
}

I thought it would be as simple as putting something like

$$('li[id="0"]:after').show();

or maybe

$$('li[id="1"]:after').css("display" : "block");

but these does not work.

  • 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-06-12T19:11:01+00:00Added an answer on June 12, 2026 at 7:11 pm

    When you handle with :after and :before, you can normally only change the content value by recurring to the data-content property (see for instance this thread)!
    However, you can do something more, e.g. you can replace the way the CSS code related to :after and :before is rendered by using a dirty trick.

    What I do is to remove the class associated with the :after or :before that I need to change, then I create a new class in the document and I apply it to the target element(s).

    I will make an brief example using the so nice CSS3 triangles.
    Suppose you have a class arrow-up and that you use :after to print a triangle with css on top of a div. Here follows a CSS.

    .div{position:relative;display:block; width:100px; height:50px; border:1px solid black}
    
    .arrow-up:after {
        content:"";
        position:absolute;
        top:-10px;
        left:50%;
        margin-left:-5px;
    width: 0; 
    height: 0; 
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;   
    border-bottom: 10px solid #333;
    }
    

    Here follows a related piece of HTML

    <div>My div with centered triangle on top</div>
    <div id="toBeMoved" class="arrow-up">My div with centered triangle moved a lot with JQuery</div>
    

    The intent is to put the triangle of the second div at 10% from the top-left corner instead of the default value (at center). Hence, we can use JQuery to remove the old class, append a new customized class to the head and apply the new class with the new :after css code to the div.

    var counter = 0;
    
    $.fn.moveTheArrow = function() {
    
      $(this).removeClass('arrow-up');
      var modclass = 'arrow-up' + (counter++);
      $("<style type='text/css'> ." + modclass + ":after{left:10%;content:'';position:absolute;top:-10px;margin-left:-5px;width: 0;height: 0;border-left: 10px solid transparent;border-right: 10px solid transparent;border-bottom: 10px solid #333}</style>").appendTo("head");
      $(this).addClass(modclass);
    
    });
    

    Notice that I defined a global counter to address for unique id generator (of course you can follow other ways as well).

    Finally, use JQuery to call the function on the target div, e.g.

    $(function(){
      $('#toBeMoved').moveTheArrow();
    });
    

    Here follows a working JSFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so i am currently making a game (a huge one over 3500 lines of
I am currently making a context menu which open from left button click instead
I am currently making a website that includes a menu navigation almost identical to
I'm currently making a little navigation menu. In one of those dropdown menus, I
I am currently making a website that includes a menu navigation almost identical to
Currently making a global volunteer site, and the webpages will more or less have
I'm currently making changes to an older version of my app for customers still
I am currently making a program which is supposed to prompt the user to
I'm currently making an application with Backbone.js and some JQuery libraries. Today I work
I am currently making a program that will send an email if the date

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.