| View previous topic :: View next topic |
| Author |
Message |
Krabik Enthusiastic Coder
Joined: 15 Mar 2005 Posts: 62
|
hey, I want to be able to change text to an image when the user puts thier mouse over it, is this possible without using another image instead of text?? Anyone know how?
Reply with quote
|
| |
|
|
Jake Enthusiastic Coder
Joined: 15 Mar 2005 Posts: 68
|
There's a couple ways to do it, one would be to use the onmouseover event on a div containing the text, then use .innerHTML to change the contents of the div to an image, and back again for the mouseout.
Reply with quote
|
| |
|
|
Krabik Enthusiastic Coder
Joined: 15 Mar 2005 Posts: 62
|
could you give me a sample code possibly?? I'm still a bit confused.
Reply with quote
|
| |
|
|
Jake Enthusiastic Coder
Joined: 15 Mar 2005 Posts: 68
|
This is about a medium complex way to do it.
This goes in the HEAD:
Code:
<script type="text/javascript">
function swapimg(d,i) {
this.innerHTML = '<img src="' + i + '" />';
}
function swaptext(d,s) {
this.innerHTML = s;
}
</script>
This in the BODY:
Code:
<div id="d1" onmouseover="swapimg('d1','myimage.gif');" onmouseout="swaptext('d1','Something');">Something</div>
Reply with quote
|
| |
|
|
|