codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Mouseover Text Change  Ami2006 at 23:49 on Friday, June 16, 2006
 

I apologize if this question has been addressed already, but I don't have time right now to search through the previous inqueries to find what I need. What I want to do is a mouseover text change that is not a link. For instance, if I have the text 'Guten Tag', I want the text to change on a mouseover to 'Good Day', as a rollover translation type thing. I found a code that's supposed to do this, but it doesn't work:

<script type="text/javascript">
var oldText="";
function replaceText(elem, newText) {
oldText=elem.firstChild.data;
elem.firstChild.data=newText;
}
function restoreText(elem) {
elem.firstChild.data=oldText;
}
</script>
<span onmouseover="replaceText(this, 'Good Day');" onmouseout="restoreText(this)">Guten Tag</span>


Any advice/help?

  Re: Mouseover Text Change  Vallim at 11:35 on Monday, June 19, 2006
 

Hi,

To change the text on mouseover event you can use the following code, as

Script

<script type=text/javascript>
function changeme()
{
document.getElementById("b1").innerText= "Good Day";
}
function restoreme()
{
document.getElementById("b1").innerText= "Guten Tag";
}
</script>

Html Code

<span id="b1" onmouseover="changeme()" onmouseout="restoreme()">Guten Tag</span>

Regards,
Valli









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Mouseover Text Change
•  Batched sort replacement algorithm
•  about visual basic
•  Numbered output from text.
•  opening a second window
•  form validation(arabic/persian language)
•  Function to check the pattern(i.e 1A-2B-3C)
•  function call from multiple rows
•  OpenFileDialog


Recent Articles
What is a pointer in C?
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net


© Copyright codetoad.com 2001-2006