Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Make a Javascript Image Rollover

Learn how to make a javascript image rollover with clear steps, practical context, and useful troubleshooting guidance.

Table of Contents

This updated guide examines How to Make a Javascript Image Rollover and organizes the essential facts, background, and practical takeaways in clear American English.

Steps

  1. How to Make a Javascript Image Rollover — contextual image 1 Prepare two images for the rollover effect. Select two different images to make a rollover image and save them in the same folder where you will save your HTML file displaying a rollover image.
  2. How to Make a Javascript Image Rollover — contextual image 2 Open any text editor of your choice. Dreamweaver will be used as the text editor in this article. Otherwise, if your text editor is blank when you open it, you need to enter HTML elements to build a web page.
  3. How to Make a Javascript Image Rollover — contextual image 3 Locate thesection. JavaScript code will be inserted within thetag. Two JavaScript functions will be created to change the images. The two functions are namedMouseRolloverandMouseOutin the code below. The image's src property will be used to change the image's source when those two functions are called.
  4. How to Make a Javascript Image Rollover — contextual image 4 Copy the following JavaScript code:
    functionMouseRollover(MyImage){MyImage.src="MyPicture2.jpg";}functionMouseOut(MyImage){MyImage.src="MyPicture1.jpg";}
  5. How to Make a Javascript Image Rollover — contextual image 5 Paste the JavaScript code in between thesection onto your text editor. TheMyPicture2.jpgin the functionMouseRollovershould be replaced by your rollover image's name and theMyPicture1.jpgin the function calledMouseOutshould be replaced by your original image's name.
  6. How to Make a Javascript Image Rollover — contextual image 6 Locate thesection. The image tagwill be applied to display the rollover image. In this example, theAlt='Title'that refers to the image title's name is omitted.
  7. How to Make a Javascript Image Rollover — contextual image 7 Copy the following code:
    div>
  8. How to Make a Javascript Image Rollover — contextual image 8 Paste the code in between thesection. Theonmouseoverproperty is added inside the image tag above and will be assigned to call the JavaScript functionImage Rolloverto change your original image to a new rollover image. ReplaceMyPicture1.jpgwith your original image's name. Moreover, another property calledonMouseOutis added to change the image back into its original one when you move your mouse away from the rollover image.
  9. How to Make a Javascript Image Rollover — contextual image 9 Review the entire code. Your code should look similar to the code below. You can play around with the code from this example and see how things change.
    How to Make a JavaScript Image Rollovertitle><scriptlanguage="javascript">functionMouseRollover(MyImage){MyImage.src="MyPicture2.jpg";}functionMouseOut(MyImage){MyImage.src="MyPicture1.jpg";}script>head><body><divalign="center"><imgsrc="MyPicture1.jpg"boarder="0px"width="650px"height="550px"onMouseOver="MouseRollover(this)"onMouseOut="MouseOut(this)"/>div>body>html></pre>
    </li>
    <li id="step-id-09"><img src="/data/images/how-to-make-a-javascript-image-rollover-picture-10-JAcGpY9ol.jpg" loading="lazy" decoding="async" alt="How to Make a Javascript Image Rollover — contextual image 10"> <strong>Click 'File' and select 'Save.'</strong></li>
    <li id="step-id-010"><img src="/data/images/how-to-make-a-javascript-image-rollover-picture-11-kOXYLrbJ3.jpg" loading="lazy" decoding="async" alt="How to Make a Javascript Image Rollover — contextual image 11"> <strong>Enter a name to save your HTML document.</strong> 'index.html' is used to test the file. Select 'Save as type' to HTML documents.</li>
    <li id="step-id-011"><img src="/data/images/how-to-make-a-javascript-image-rollover-picture-12-Qpzsussnm.jpg" loading="lazy" decoding="async" alt="How to Make a Javascript Image Rollover — contextual image 12"> <strong>Click the 'Save' button.</strong></li>
    <li id="step-id-012"><img src="/data/images/how-to-make-a-javascript-image-rollover-picture-13-E6IVF8Xco.jpg" loading="lazy" decoding="async" alt="How to Make a Javascript Image Rollover — contextual image 13"> <strong>Preview the finished web page in a browser.</strong> Click 'File' and then go to 'Preview in Browser.' Click 'Firefox' or any Web browser being installed in your text editor.</li>
    </ol>
    <section class="faq">
    <h2 id="faq">FAQ</h2>
    <h3 id="what-is-how-to-make-a-javascript-image-rollover-about">What is How to Make a Javascript Image Rollover about?</h3>
    <p>It provides a structured overview of image, explains the main context, and highlights practical takeaways for readers.</p>
    <h3 id="why-does-this-topic-matter">Why does this topic matter?</h3>
    <p>Understanding the main concepts helps readers evaluate the issue, avoid common mistakes, and make better-informed decisions.</p>
    <h3 id="how-should-readers-use-this-information">How should readers use this information?</h3>
    <p>Use the guidance as a practical starting point, confirm details that may have changed, and follow current product, safety, or security recommendations.</p>
    </section></div>
    <nav class="article-pagination" aria-label="Article navigation">
    <a class="article-page-link article-page-prev" href="https://tipsmake.com/how-to-create-a-javascript-console-in-sublime-text" rel="prev"><span class="article-page-label"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"></path></svg>Previous article</span><strong>Build: How to Create a Javascript Console in Sublime Text</strong></a><a class="article-page-link article-page-next" href="https://tipsmake.com/how-to-make-a-basic-javascript-quiz" rel="next"><span class="article-page-label">Next article<svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"></path></svg></span><strong>HTML: How to Make a Basic Javascript Quiz</strong></a></nav>
    <section class="comments-section" id="comments" data-comments data-article="41718" aria-labelledby="comments-title">
    <div class="comments-heading">
    	<div>
    		<span class="eyebrow">Discussion</span>
    		<h2 id="comments-title">Reader Comments <span class="comment-count" data-comment-count>0</span></h2>
    	</div>
    	<button type="button" class="btn" data-open-auth>Sign In to Comment</button>
    </div>
    <div class="comment-member" data-comment-member hidden><span>Signed in as: <strong data-user-name></strong></span><button type="button" class="text-button" data-logout>Sign Out</button></div>
    <div class="comment-guest" data-comment-guest><p>Sign in with email or Google to join the discussion.</p></div>
    <form id="comment-form" class="comment-form" hidden><label for="comment-body">Comment</label><textarea id="comment-body" name="body" minlength="5" maxlength="2000" required placeholder="Share your thoughts…"></textarea><input type="text" class="honeypot" name="website" tabindex="-1" autocomplete="off" aria-hidden="true"><div class="comment-form-footer"><small>Maximum 2,000 characters</small><button class="btn" type="submit">Post Comment</button></div></form>
    <div class="comments-status" data-comments-status aria-live="polite"></div><div class="comments-empty" data-comments-empty hidden>No comments yet. Be the first to share your thoughts.</div><div class="comments-list" data-comments-list></div><button type="button" class="btn secondary load-comments" data-load-comments hidden>Load More Comments</button>
    </section><section class="related-section" aria-labelledby="related-title">
    <div class="section-head"><h2 class="section-title" id="related-title">Related Articles</h2></div>
    <div class="related-grid">
    <a class="related-card" href="/animation-in-javascript"><span class="related-thumb blue"><img loading="lazy" decoding="async" src="/data/thumbs_200x120/animation-in-javascript_thumbs_200x120_1hdsuOSf2.jpg" alt="Animation in JavaScript"></span><strong>Animation in JavaScript</strong><small>3 minutes read</small></a><a class="related-card" href="/image-map-in-javascript"><span class="related-thumb blue"><img loading="lazy" decoding="async" src="/data/thumbs_200x120/image-map-in-javascript_thumbs_200x120_c23nSr3UG.jpg" alt="Image Map in JavaScript"></span><strong>Image Map in JavaScript</strong><small>3 minutes read</small></a><a class="related-card" href="/syntax-of-javascript"><span class="related-thumb blue"><img loading="lazy" decoding="async" src="/data/thumbs_200x120/syntax-of-javascript_thumbs_200x120_0PJ4dvKA7.jpg" alt="Syntax of JavaScript"></span><strong>Syntax of JavaScript</strong><small>1 minutes read</small></a><a class="related-card" href="/top-site-with-many-good-javascript-exercises-to-practice"><span class="related-thumb blue"><img loading="lazy" decoding="async" src="/data/thumbs_200x120/top-site-with-many-good-javascript-exercises-to-practice_thumbs_200x120_vIwlOMzbJ.jpg" alt="Top Site with Many Good JavaScript Exercises to Practice"></span><strong>Top Site with Many Good JavaScript Exercises to Practice</strong><small>4 minutes read</small></a><a class="related-card" href="/what-is-javascript-can-the-internet-exist-without-javascript"><span class="related-thumb blue"><img loading="lazy" decoding="async" src="/data/thumbs_200x120/what-is-javascript-can-the-internet-exist-without-javascript_thumbs_200x120_VJeAJw6qa.jpg" alt="What Is JavaScript? Can the Internet Exist Without JavaScript?"></span><strong>What Is JavaScript? Can the Internet Exist Without JavaScript?</strong><small>11 minutes read</small></a><a class="related-card" href="/summary-of-javascript-exercises-with-sample-code"><span class="related-thumb blue"><img loading="lazy" decoding="async" src="/data/thumbs_200x120/summary-of-javascript-exercises-with-sample-code_thumbs_200x120_9USpW8MLA.jpg" alt="Summary of JavaScript Exercises with Sample Code"></span><strong>Summary of JavaScript Exercises with Sample Code</strong><small>15 minutes read</small></a></div>
    </section>
    </article>
    <aside class="sidebar">
    <section class="widget">
    <h2 class="widget-title">You might be interested</h2>
    <div class="trend-list">
    <div class="trend-item"><a href="https://tipsmake.com/how-to-safely-post-photos-of-your-baby-online">How to Safely Post Photos of Your Baby Online</a></div><div class="trend-item"><a href="https://tipsmake.com/how-to-search-by-image">How to Search by Image: Step-by-Step Guide</a></div><div class="trend-item"><a href="https://tipsmake.com/how-to-make-an-avatar">How to Make an Avatar: Step-by-Step Guide</a></div><div class="trend-item"><a href="https://tipsmake.com/how-to-save-a-bing-background-image">How to Save a Bing Background Image: Step-by-Step Guide</a></div><div class="trend-item"><a href="https://tipsmake.com/how-to-embed-pictures">How to Embed Pictures: Step-by-Step Guide</a></div><div class="trend-item"><a href="https://tipsmake.com/how-to-get-the-url-for-pictures">How to Get the URL for Pictures: Step-by-Step Guide</a></div></div>
    </section>
    <section class="widget toc-box" data-toc>
    <h2 class="widget-title">In This Article</h2>
    <a href="#steps">Steps</a><a href="#faq">FAQ</a><a href="#what-is-how-to-make-a-javascript-image-rollover-about">What is How to Make a Javascript Image Rollover about?</a><a href="#why-does-this-topic-matter">Why does this topic matter?</a><a href="#how-should-readers-use-this-information">How should readers use this information?</a><a href="#comments">Discussion</a>
    </section>
    </aside>
    </div>
    </div>
    </main>
    <footer class="site-footer">
    
        <div class="container footer-grid">
    
            <div class="footer-brand">
    
                <a class="brand" href="/" aria-label="TipsMake">
                    <span class="footer-logo-text">
                        Tips<strong>Make</strong>
                    </span>
                    <span class="footer-logo-domain" aria-hidden="true">.com</span>
                </a>
    
                <p>Practical Technology Knowledge.</p>
    
            </div>
    
            <div class="footer-col">
                <h2>Topics</h2>
    
                <a href="/c/technology/">Technology</a>
                <a href="/c/system/">System</a>
                <a href="/c/windows-11/">Windows 11</a>
                <a href="/c/artificial-intelligence/">AI</a>
                <a href="/c/security-solution/">Security</a>
            </div>
    
            <div class="footer-col">
                <h2>Resources</h2>
    
                <a href="/utility-assets/">Utility Lab</a>
                <a href="/tools/">Free Tools</a>
                <a href="/learn/">Learning Library</a>
            </div>
    
            <div class="footer-col">
                <h2>TipsMake</h2>
    
                <a href="/about.htm">About</a>
                <a href="/contact.htm">Contact</a>
                <a href="/terms.htm">Terms</a>
                <a href="/privacy.htm">Privacy</a>
            </div>
    
        </div>
    
        <div class="container footer-bottom">
            <span>© <b id="year">2026</b> TipsMake.com</span>
            <span>All rights reserved.</span>
        </div>
    
    </footer><div class="search-panel" role="dialog" aria-modal="true" aria-label="Search"><div class="search-box"><button type="button" class="search-close" aria-label="Close">×</button><h2>Search TipsMake</h2><form action="/search.htm"><input id="site-search" class="search-input" name="keystips" type="search" placeholder="Windows, AI, security…" aria-label="Keywords"><button type="submit" class="btn">Search</button></form></div></div><div class="auth-modal" id="auth-modal" role="dialog" aria-modal="true" aria-labelledby="auth-title" hidden>
    <div class="auth-card"><button type="button" class="auth-close" data-close-auth aria-label="Close sign-in">×</button><h2 id="auth-title">Join the Discussion</h2><p class="auth-intro">Sign in to comment and follow the discussion.</p><div class="auth-tabs" role="tablist"><button type="button" class="active" role="tab" aria-selected="true" data-auth-tab="login" id="auth-login-tab">Sign In</button><button type="button" role="tab" aria-selected="false" data-auth-tab="register" id="auth-register-tab">Create Account</button></div>
     <div id="auth-login-panel" role="tabpanel" aria-labelledby="auth-login-tab" tabindex="0">
    <form class="auth-form" data-auth-form="login" ><label>Email<input type="email" name="email" autocomplete="email" required></label><label>Password<input type="password" name="password" autocomplete="current-password" required></label><button class="btn" type="submit">Sign In</button></form></div>
    <div id="auth-register-panel" role="tabpanel" aria-labelledby="auth-register-tab" tabindex="0">
    <form class="auth-form" data-auth-form="register" hidden><label>Display Name<input type="text" name="name" autocomplete="name" minlength="2" maxlength="60" required></label><label>Email<input type="email" name="email" autocomplete="email" required></label><label>Password<input type="password" name="password" autocomplete="new-password" minlength="8" maxlength="72" required></label><small>Password must contain at least 8 characters, including letters and numbers.</small><button class="btn" type="submit">Create Account</button></form></div>
    <div class="auth-divider"><span>or</span></div><div class="google-button" data-google-button></div><p class="google-note" data-google-note></p><div class="auth-status" data-auth-status aria-live="polite"></div><p class="auth-legal">By continuing, you agree to the <a href="terms.htm">Terms</a> and <a href="privacy.htm">Privacy Policy</a>.</p></div>
    </div><script src="/template/tech-nova/assets/comments.js" defer></script>
    </body>
    </html>