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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:00:32+00:00 2026-06-08T07:00:32+00:00

I can’t see why this isn’t working. I have a list, each item has

  • 0

I can’t see why this isn’t working. I have a list, each item has a background image on the anchor. With jQuery I’m trying to remove the background image on the item right before the selected anchor. Here is the HTML:

<ul id="menu">
<li class="last"><a href="#">Contact Us</a></li>
<li><a href="#">Testimonials</a></li>
<li><a href="#">Projects</a></li>
<li class="selected"><a href="#">Our Services</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Home</a></li>
</ul>

And here is the jQuery I am using to try and remove the background image (using display:none for testing purposes):

$('li.selected a').prev().css( {display : "none"});

When I use the following, it works:

$('li.selected').prev().css( {display : "none"});

But as soon as I involve the anchor tag, it stops.

TLDR: Basically I need to select “projects” which is before the selected link, and remove its background image tied to it (to the link, not the list item). Can anyone tell me why that code isn’t working?

Thanks

  • 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-08T07:00:34+00:00Added an answer on June 8, 2026 at 7:00 am

    The <a> link in $('li.selected a') has no previous element. It’s alone as a child of the list element. You would need to go up one level in the DOM to the <li> and then use .prev.

    Like $('li.selected a').parent().prev().css( {display : "none"});​

    jsFiddle example

    Or for your specific need:

    $('li.selected a').parent().prev().children('a').css( {backgroundImage : "none"});​​​​​​​​​​​​​​​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
Can't figure out how to do this in a pretty way : I have
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can a DateTime value be NULL ? I have this code: From here I
Can I order my users in the database, so I don't have to say
Can anyone explain to me why this program: for(float i = -1; i <
Basically, what I'm trying to create is a page of div tags, each has
Can I run this in a Windows command prompt like I can run it
Can anybody help me? What should be the datatype for this type -07:00:00 of
can someone explain why the compiler accepts only this code template<typename L, size_t offset,

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.