advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
Tip of the Day
Expertise: All
Language: Web
May 26, 1999
Use innerText in DHTML to Change Text on the Fly

      Register for free to read this and other premium DevX content!

      Already Registered? Click here to Login

  • About You

  • Contact Information

  • - -      Ext: (optional)
  • Company Information




  • Create Password

With Dynamic HTML and Internet Explorer 4 and 5 you can update the text on the page after the page is rendered. The trick is to use the ID attribute as a unique identifier for the tag. As the user rolls the cursor over the text, the onmouseover event replaces the text between the opening and closing tags. Here's a short example:

<HTML>
<BODY>
<p id="mytext"
onmouseout="mytext.innerText='Short description';"
onmouseover="mytext.innerText='Longer description of the same item using DHTML for IE.';">
Short description
</p>
</BODY>
</HTML>
You can restore the original text by including it as part of the onmouseout event.
Ken Cox
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
advertisement
advertisement