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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:46:23+00:00 2026-05-27T21:46:23+00:00

How can I using jQuery make the image inside of a div change to

  • 0

How can I using jQuery make the image inside of a div change to another image on mouse over? I have a div that holds inside of it an image, a header, and some text. I want to make the image change on mouse over.

Also the template I use uses a lot of jquery but the files are all over the place. Where should I put the function?

Here is an Image of the DIV

EDIT: Here’s the code I have so far:

CSS:

#tour {
    overflow:hidden;
    width:100%;
    padding:56px 0 47px
}

#tour #link {
    height:auto;
    width:200px; /* 140px + 60px */
    float:left;
    margin-right:25px;
    margin-left:10px;   

}

#tour #link:hover {
    cursor:pointer;
}

#tour img {
    /* Float the image to the left of text */
    width:50px;
    float: left;
    margin-right:10px;
    height:auto;
}

#tour h1, h2, h3, h4 {
    display:block;
    width:140px;
    float:left;
}

#tour p, #tour p.last {
    display:table-row;
    width:140px;
    alignment-baseline:baseline;
    /* Custom added */
    color: #333;
    font-size: 10px;
    margin: 5px;
    font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif;
    font-size: 11px;
    width: 140px;   
}

HTML:

<div id="tour"> 
   <div id="link" onclick="location.href='#';"  >               
      <img src="images/icn1.png" alt="" />
      <h2>Pitch</h2>
      <p>Present your ideas in a manner that will leave your customers in amazement.</p>
   </div>
 </div>
  • 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-27T21:46:24+00:00Added an answer on May 27, 2026 at 9:46 pm
    $('div#imageContainer').on('mouseover', function(){
        $(this).children('img').attr('src','../newImage.png');
    });
    

    That’ll do it. Doesn’t matter where you put the code, as long as it’s within the $(document).load(function(){...});

    NOTE: this is using the latest jQuery 1.7.1 .on() function which is new to this version. Same thing can be accomplished with .bind()

    Update for comments:

    If you want to keep this function in a separate file, you can wrap it in a function

    function imageSwap(){
        $('div#imageContainer').on('mouseover', function(){
            $(this).children('img').attr('src','../newImage.png');
        });
    }
    

    And then just call the imageSwap() function from within the document load.

    Also, if you want to use this on multiple divs with different images, you can do one of two things. Either A) name your images something like img1_over.png and img1.png, in which case you can modify the code as such:

    $('div#imageContainer').on('mouseover', function(){
        var img = $(this).children('img');
        img.attr('src', img.attr('src').replace('.png', '_over.png'));
    });
    

    Or you can store the image path in a data attribute on the image themselves. In your HTML you would add the hover image to a data attribute like so:

    <img src="../cool_img.png" data-hover="../ever_cooler_image.png" />
    

    And your code would look like this:

    $('div#imageContainer').on('mouseover', function(){
        var img = $(this).children('img');
        img.attr('src', img.data('hover'));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can we make the jQuery plugnin to return the wrapped set?so that using
I wish I can make an image gallery without using jQuery plugin. Which all
I'm trying to make a drop down menu using javascript/jquery but can't get my
Can I send email using jQuery only? I don't have .Net or PHP etc
How can I manipulate using JavaScript (JQuery) a site, not in my server, that
How can i fadeOut a div using jquery
I have a jQuery problem that I can't seem to work out on my
I have made a simple web page using jQuery. When opening it on another
I'm wondering how can I put a div over every image element on the
I have 4 divs in the image below. Each div is a link that

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.