Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

JavaScript onmouseover/onmouseout

pbusig

New Coder
I have been working on re-learning Javascript and am currently trying to use onmouseover and onmouseout to change a photo in my page to another photo, So far I have had no luck. When I open my page it does not load my photo, it loads the alternate text, so I know that this part of the code is not working correctly, and when I mouseover the alternate text the photo changes to the second photo, however when I mouseout it does not change back. I know this is probably a lame question to have to ask and that I should be ashamed to not get this figured out for myself, so please forgive me. Here is my Code:

This is the code from my html page:

<img id="demo4" onmouseover="Melanie(this)" onmouseout="Kiki(this)" border="0" src="/images/Kiki.jpg" alt="Kiki" width="32" height="32">

These are my functions from my myscript.js file:

function Melanie(x) {

document.getElementById("demo4").innerHTML = "<img src= images/Melanie.jpg>";

}

function kiki(x) {

document.getElementById("demo4").innerHTML = "<img src= images/Kiki.jpg>";
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom