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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:33:34+00:00 2026-05-27T01:33:34+00:00

The JavaScript below only replaces the src for one image on a page how

  • 0

The JavaScript below only replaces the src for one image on a page how can i get it to do it for multiple images on the same page

<SCRIPT LANGUAGE="JavaScript">

loadImage1 = new Image();
loadImage1.src = "http://4.bp.blogspot.com/-Xzm-yUJ_dz0/Tsj3Q57J2tI/AAAAAAAAAGE/bohLMRj5FCY/s1600/hover.png";

staticImage1 = new Image();
staticImage1.src = "http://3.bp.blogspot.com/--0FurTdrYzg/Tsj3RPXGz4I/AAAAAAAAAGI/mm_4UvmoD-A/s1600/standard.png";

replaceImage1 = new Image();
replaceImage1.src = "http://4.bp.blogspot.com/-oacZCbBUhQ0/Tsj3Qkl4IaI/AAAAAAAAAGA/5_z-2VXKCi8/s1600/clicked.png";

</script>

The Image HTML is below if required.I don’t mind applying and ID or CLASS to the images either 🙂

<img onMouseOver="image1.src=loadImage1.src;" onMouseOut="image1.src=staticImage1.src;" onmousedown="image1.src=replaceImage1.src;" onmouseup="image1.src=loadImage1.src;" style=width:480px;height:360px;background-image:url('http://i1.ytimg.com/vi/XtNcZnfkL2A/hqdefault.jpg');" name="image1" src="http://3.bp.blogspot.com/--0FurTdrYzg/Tsj3RPXGz4I/AAAAAAAAAGI/mm_4UvmoD-A/s1600/standard.png">

AND/OR is there a cleaner jquery for this I would much rather use jQuery, thankyou!

  • 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-27T01:33:34+00:00Added an answer on May 27, 2026 at 1:33 am

    You can do it as:
    Add a class to images , like;

    <img class='someclass' ....
    

    Then using jQuery you can select all the images having the same classname, like;

    $("img[class='someClass']").each(function() {
       //replace src attribute of each image
       $(this).attr("src", "");
       $(this).attr("src", "your_new_src");
    });
    

    Hope it helps

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

Sidebar

Related Questions

I have a String like below: <script language=JavaScript type=text/javascript src=http://dns.net/adj/myhost.com/index;size=5x10;zipc=12345;myzon=north_west;|en;tile=10;ord=7jkllk456?></script> I want to access
The Javascript below has a default image, but I would like display text only
the Javascript below only works as for youtube videos actual url. <script> regex =
[edit] So I used one of the javascript tooltips suggested below. I got the
How to generate page numbers like the below using javascript/jquery? If the 5 th
I'm hoping someone can explain to me why the below JavaScript/HTML will show door
Using jQuery autocomplete.. Want to replace hello in script below with javascript to identify
This will animate the second image after the first animation is complete: <script type=text/javascript>
I am able to display my tweets in my website using the JavaScript below.
Yesterday I moved CultureRater.com across to XHTML 1.0 Transitional and while the javascript below

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.