BabaFree Posted September 25, 2006 Share Posted September 25, 2006 Hey Everyone.Ok, I've Googled, searched on this forum and others, and even tried to make stuff up (which generally doesn't work, but you never know), and I'm batting 0.000 so far. Chalk it up to Javascript ignorance. What I want to do is have the contents of a specific <div> change when I hover the mouse over an image that is in a separate div:I've gotten the closest with the following: <img src="images/testbut1.png" onmouseover="document.getElementById('changing').innerHTML = 'hello'"> which works perfectly and I see "hello" show up in the target div! I get happy and start thinking that the last two hours have finally paid off. Then I put the following: <img src="images/testbut2.png" onmouseover="document.getElementById('changing').innerHTML = '<img src="images/ad_sundaysermon.jpg">'"> Heart plummets and elation gone. Nothing happens and these characters are displayed after my testbut2.png:'">Can anyone tell me what I'm doing wrong? Or simply present a better way of doing what I'm trying? Any help would be greatly appreciated.Thanks,Brandon Link to comment Share on other sites More sharing options...
skym Posted September 25, 2006 Share Posted September 25, 2006 Check the quotes.To avoid the problems like this, you better use separate functions instead of inline javascript, like: <script>function chenge() {document.getElementById('changing').innerHTML = '<img src="images/ad_sundaysermon.jpg">';}</script><img src="images/testbut2.png" onmouseover="change();"> Link to comment Share on other sites More sharing options...
BabaFree Posted September 25, 2006 Author Share Posted September 25, 2006 Thanks a lot for the tip. I'll try it out tonight after work.Brandon Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now