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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:05:00+00:00 2026-06-01T20:05:00+00:00

i am really new with JavaScript. I new to click an image, that image

  • 0

i am really new with JavaScript. I new to click an image, that image will change SRC and the others too.

This is the code:

<a href="#pduno"><img onclick="this.src='img/pduno.png';document.getElementsByClassName('imgdp').src='img/pddos.png'" class="imgdp" src="img/pduno.png" width="13" height="11" /></a> 
<a href="#pddos"><img onclick="this.src='img/pduno.png';document.getElementsByClassName('imgdp').src='img/pddos.png'" class="imgdp" src="img/pddos.png" width="13" height="11" /></a>
<a href="#pddos"><img onclick="this.src='img/pduno.png';document.getElementsByClassName('imgdp').src='img/pddos.png'" class="imgdp" src="img/pddos.png" width="13" height="11" /></a>

pduno.png is the “active” image and pddos.png is the “desactive” image.

Let’s image I have 3 images pduno – pddos – pddos

When I click one of the 2 pddos, it change to pduno and the one that was pduno change to pddos. I mean, there will be only one image with pduno while the rest are pddos.

I am using this to create a scroll gallery. The pduno works to show what gallery is being showed.

  • 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-01T20:05:01+00:00Added an answer on June 1, 2026 at 8:05 pm

    I would use the jQuery library for that (because you need to use some not-so-simple functions)

    You can include it writing this code (no need to download anything):

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />
    

    And then, I would do this:

    <a href="#pddos"><img class="pdimg" src="img/pduno.png" width="13" height="11" /></a>
    <a href="#pddos"><img class="pdimg" src="img/pddos.png" width="13" height="11" /></a>
    <a href="#pddos"><img class="pdimg" src="img/pddos.png" width="13" height="11" /></a>
    

    In the HTML, I removed all the scripts, and moved them here:

    <script>
    $('.pdimg').click(function(){ //This registers the function with the click event
        $('.pdimg').attr('src', 'img/pddos.png'); //This resets the image to pddos
        $(this).attr('src', 'img/pddos.png'); //This sets the image to uno, 
                                 // "this" will be the img that you clicked on.
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm really new to JavaScript and jQuery. My question is this. I have two
Yo. I'm really quite new to this whole JavaScript business, not to mention AJAX,
I'm new to javascript/jQuery this really has me stumped. What I'm trying to achieve
I'm pretty new to jQuery (and javascript for that matter), so this is probably
I have a form that generates new input fields via JavaScript on click. the
Cletus helped my with this really sweet code yesterday: what javascript object am I
This seems really simple but Im brand new to JavaScript. I have a link
I'm really new to ASP.NET MVC, and I'm trying to integrate some Javascript into
im really new to linq-to-SQL so this may sound like a really dumb question,
I'm really new to VSTO so sorry if this is a newbie question. I'm

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.