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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:11:20+00:00 2026-05-11T16:11:20+00:00

This question completes the first one that I asked here about how to change

  • 0

This question completes the first one that I asked here about how to change an image on click using jQuery.

I forgot to say (even if I edited my post later) that I’m looking for a way to have a different alt attribute each time an image is changed by click.

(This is for better accessibility and SEO optimization.)

Here is the actual html code thanks to altCognito:

<img id="radio_btn1" src="originalimage1.jpg" />
<br />
  <input type="radio" name="radio_btn1" value='image1.jpg' />
  <input type="radio" name="radio_btn1" value='image2.gif' />
  <input type="radio" name="radio_btn1" value='image3.png' />
  <input type="radio" name="radio_btn1" value='image4.jpeg' />

And the jquery:

imgFldr = 'images/nameofthesubfolder/';
$("input[type='radio']").click(function() {
   $('#'+this.name).attr('src', imgFldr+this.value).attr('alt', 'newattribute');
});

It can be edited at jsbin.

  • 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-11T16:11:20+00:00Added an answer on May 11, 2026 at 4:11 pm

    Well… SEO and content manipulated by Javascript shouldn’t be in the same post to begin with. Whatever you do, if you use Javascript to display your content, you’re hurting your search engine visibility.

    That said, you could either have those images in a hasharray (imagename->alt) and get the alt from there, or you could put the alt in the value of the radio concatenated to the filename with a separator like | and then parse them out in the function you use to display the image.

    …so in short either:

    <img id="radio_btn1" src="originalimage1.jpg" />
    <br />
      <input type="radio" name="radio_btn1" value='image1.jpg|Image 1' />
      <input type="radio" name="radio_btn1" value='image2.gif|Image 2' />
      <input type="radio" name="radio_btn1" value='image3.png|Image 3' />
      <input type="radio" name="radio_btn1" value='image4.jpeg|Image 4' />
    

    +

    imgFldr = 'images/nameofthesubfolder/';
    $("input[type='radio']").click(function() {
       var strarr = this.value.split('|');
       if(strarr.length < 2) return;
       $('#'+this.name).attr('src', imgFldr+strarr[0]).attr('alt', strarr[1]);
    });
    

    …or:

    <img id="radio_btn1" src="originalimage1.jpg" />
    <br />
    <input type="radio" name="radio_btn1" value='image1.jpg' />
    <input type="radio" name="radio_btn1" value='image2.gif' />
    <input type="radio" name="radio_btn1" value='image3.png' />
    <input type="radio" name="radio_btn1" value='image4.jpeg' />
    

    +

    imgFldr = 'images/nameofthesubfolder/';
    var imagesarr = {'image1.jpg': 'Image 1', 'image2.gif': 'Image 2','image3.png': 'Image 3','image4.jpeg': 'Image 4'}
    $("input[type='radio']").click(function() {
       $('#'+this.name).attr('src', imgFldr+this.value).attr('alt', imagesarr[this.value]);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 164k
  • Answers 164k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Make the FilterBase class itself generic. public abstract class FilterBase<T>… May 12, 2026 at 12:26 pm
  • Editorial Team
    Editorial Team added an answer If you have all the time in the world, why… May 12, 2026 at 12:26 pm
  • Editorial Team
    Editorial Team added an answer You can alter the current IP address by writing a… May 12, 2026 at 12:26 pm

Related Questions

This question is about the same program I previously asked about . To recap,
The idea of storing connection strings in a data base is a perverse idea,
I know the question about measuring developer performance has been asked to death, but
I'm a bit in IDE trouble, and I'm not alone I have noticed, still

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.