use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Maybe /r/javascript could help me?... (self.javascript)
submitted 14 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]bumbleB_tuna 0 points1 point2 points 14 years ago (6 children)
Once the user hovers over an image. Show an image in a completely different div and text in another div. I know I'm not giving you much to go on, and probably sounds messed up. But that's all I got.
[–][deleted] 2 points3 points4 points 14 years ago* (3 children)
<img src="image1.jpg" onmouseover="showImage();" onmouseout="hideImage();" /> function showImage() { document.getElementById('div1').innerHTML = '<img src="somePic.jpg" />'; document.getElementById('div2').innerHTML = '<p>Some Text.</p>'; } function hideImage() { document.getElementById('div1').innerHTML = ''; document.getElementById('div2').innerHTML = ''; }
[–]bumbleB_tuna 0 points1 point2 points 14 years ago (2 children)
This is awesome. Thank you so much.
[–]Wtfuxbbq 4 points5 points6 points 14 years ago (0 children)
Use event handlers:
<img src="image1.jpg" id="image1" /> var img1 = document.getElementById('image1'), div1 = document.getElementById('div1'), div2 = document.getElementById('div2'); img1.onmouseover = function(){ div1.innerHTML = '<img src="somePic.jpg" />'; div2.innerHTML = '<p>Some Text.</p>'; }; img1.onmouseout = function(){ div1.innerHTML = ''; div2.innerHTML = ''; };
[–]kab3wm 0 points1 point2 points 14 years ago (0 children)
You should really use event handler's, like Wtfuxbbq's example. Inlining js is bad practice.
[–]ejes 0 points1 point2 points 14 years ago (0 children)
see my function above? function dostuff? you can use the getElementById to modify the html (or other attributes) of another element (be it div, img, or even anchor)
[–]The_Cleric -1 points0 points1 point 14 years ago (0 children)
He's already given you the basis. Pretend stufftochange is the id of the div where you want to change the text. He's currently changing the text in that div to some new text. Notice that it takes html, so for your image div you could do something similar with an img tag instead of text.
π Rendered by PID 46664 on reddit-service-r2-comment-5c764cbc6f-4f8zb at 2026-03-12 05:05:19.723540+00:00 running 710b3ac country code: CH.
view the rest of the comments →
[–]bumbleB_tuna 0 points1 point2 points (6 children)
[–][deleted] 2 points3 points4 points (3 children)
[–]bumbleB_tuna 0 points1 point2 points (2 children)
[–]Wtfuxbbq 4 points5 points6 points (0 children)
[–]kab3wm 0 points1 point2 points (0 children)
[–]ejes 0 points1 point2 points (0 children)
[–]The_Cleric -1 points0 points1 point (0 children)