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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:04:26+00:00 2026-05-21T23:04:26+00:00

I have a list of li tags with an image. When a user clicks

  • 0

I have a list of li tags with an image. When a user clicks a particular link i want to change the image. When a user clicks a new li tag then the last li tag should reset. I done everything except to set a new image for the particular li tag. And the major problem is i’m not passing any arguments to the function.

$(document).ready(function(){
    $(".sized ul li a").click(function(){
    $('.sized ul li a img').each(function(){$(this).remove(); }); // Removing all images
    $('.sized ul li a ').each(function(){$(this).append('<img src="1.png" />'); });// Reset the images
});
  • 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-21T23:04:27+00:00Added an answer on May 21, 2026 at 11:04 pm

    I don’t understand why it is a problem to not pass any arguments.

    Instead of removing and adding a new image for all links, just change the one that was clicked before. You can change the image by just changing its src attribute with .attr():

    $(function() {
        var $prev;
        $(".sized ul li a").click(function(){
            if($prev) {
                $prev.find('img').attr('src', '1.png');
            }
            $prev = $(this).find('img').attr('src', 'new-url-here').end();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have list of structure. I want to modify a particular data from the
I have a list of strings similar to this list: tags = ('apples', 'apricots',
In our HTML page, we have a list of tags to load in many
I have a list of files like this: wgEncodeCaltechRnaSeqGm12878R1x75dFastqRep1.fastq.trim.tags.sam wgEncodeCaltechRnaSeqGm12878R1x75dFastqRep2.fastq.trim.tags.sam wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep1.fastq.trim00.tags.sam wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep1.fastq.trim01.tags.sam wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep1.fastq.trim02.tags.sam wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep2.fastq.trim00.tags.sam
I have a HTML form that accepts a comma separated list of tags, which
I have what seems like a simple arrangement: a list of tags in a
I have an unordered list with a few list elements. #tags { width: 300px;
I have list of articles on the page in table and i want to
i have list of links link1 link2 link3 how can i add an image
I have image tags in my html that have empty src attributes. This causes

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.