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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:28:57+00:00 2026-05-28T14:28:57+00:00

This is basically a menu that doesn’t refresh the page. I am attempting to

  • 0

This is basically a menu that doesn’t refresh the page. I am attempting to only have one image active at a time, and am having issues deselecting the previously selected menu options. That is to say this is acting more as a check-box rather than a radio-box.

$(function(){
    $(".img-swap").live('click', function() {
        if ($(this).attr("class") == "img-swap") {
            this.src = this.src.replace("_off","_on");
        } else {
            this.src = this.src.replace("_on","_off");
        }
    });
});

Here is the code the jQuery is attempting to modify

<div id="feedback-topic.buttons">
    <a href="#bug"><img src="lib/feedback-bug_off.jpg" alt="bug" width="75" height="49" border="0" class="img-swap" /></a>
    <a href="#content"><img src="lib/feedback-site_content_off.jpg" alt="bug" width="121" height="49" border="0" class="img-swap" /></a>
    <a href="#suggestion"><img src="lib/feedback-suggestion_off.jpg" alt="bug" width="117" height="49" border="0" class="img-swap" /></a>
</div>

But I can’t figure out for the life of me how to deselect (change the src.replace) on all buttons excluding the option that was just clicked.

Also any idea how to go about passing which option was selected to the next page when the form all of this is inside is submitted? I suppose I should have an invisible form that changes based on what was selected or is there an easier means to accomplish this?

  • 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-28T14:28:58+00:00Added an answer on May 28, 2026 at 2:28 pm

    Notwithstanding your stuff about form submission, the way to toggle everything except this is to use .not(this), or $(this).siblings() if all of the matching elements are actually siblings of this:

    this.src = this.src.replace('_off', '_on');
    
    $('.img-swap').not(this).attr('src', function(index, attr) {
        return attr.replace('_on', '_off');
    });
    

    This uses the callback version of .attr() to modify the src attribute of the matching elements in place.

    Working demo at http://jsfiddle.net/alnitak/6a28q

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

Sidebar

Related Questions

I have a menu that links to content on the same page and through
I am currently building a website in codeigniter that is one page site, basically
I've been working on a small page in PHP, one that doesn't need the
I know that in C#, if you write ~MyClass() , this basically translates to
This code basically translates characters based on position in one string to the character
This is basically a math problem, but very programing related: if I have 1
I have a dropdown menu that works fine, but I would like it so,
I have the following jQuery code: $(ul.menu li a).click(function() { $(ul.menu li a).removeClass(currentMenu); $(this).addClass(currentMenu);
this is an odd one, that has eaten a lot of hours of my
I have basically the opposite problem to this question: How to prevent iframe from

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.