iLTC Home
Bookmark iLTC!

Categories

Perl
  • Perl Tutorials Beginners

  • Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

  • HTML
  • HTML Tutorials

  • Command Line
  • Command Line Tutorials

  • How Tos
  • Other Tips and Tricks



  • <script type='text/javascript'>
    2210792

    iLoveTheCode.com

    Use innerHTML to Change Text on a Page

    To use innerHTML to change text on a page:

    <p id="hu">This text will change!</p>

    <script type="text/javascript">
    function goHo() {
    hu.innerHTML="Hello";
    }
    </script>


    <a href="#" onMouseOver="goHo()" onMouseOut="hu.innerHTML='Goodbye'">Say Hi</a>


    -We used HTML's id attribute to name our paragraph hu
    -We created our function and named it goHo because it's easy to type.
    -We then used our hu attribute to define Javascript's built-in innerHTML property.
    -We said that wherever the hu tag is in our HTML, it will have a value of Hello when this function is called.

    -We then wrote a link tag.
    -We used Javascript's built-in onMouseOver handler, to call our function.
    -We then used Javascript's built-in onMouseOut handler to change our hu.innerHTML to Goodbye


    NOTES: I wrote the Javascript right into the onMouseOut handler to show the different ways the innerHTML property can be used. Note the Goodbye is in single quotes because the entire onMouseOut event should be wrapped in double quotes.



    Free Copy and Paste Javascript Code:

    <script type="text/javascript">
    <!--
    function goHo() {
    hu.innerHTML="Hello";
    }
    -->
    </script>

    <p id="hu">This text will change!</p>

    <a href="#" onMouseOver="goHo()" onMouseOut="hu.innerHTML='Goodbye'">Say Hi</a>



    Resources:
    Use OnMouseOver in Javascript
    Create a Function in Javascript
    Call your Function in Javascript
    Use onMouseOut in Javascript




    Previous Article: Focus a Window with self.focus in Javascript
    Next Article: Get Query String Using Javascript






    Search iLTC w/ Google




    Recent Articles

  • HTML Font Code
  • Javascript and CSS - Easy Pop Up Help Balloons
  • Use OnMouseOver in Javascript
  • Use onMouseOut in Javascript
  • Use innerHTML to Change Text on a Page
  • Renaming a File with Perl's RENAME Function
  • PRINT to Browser with document.write Command in Javascript
  • Passing an Argument or Variable to a Javascript
  • Opening an Alert Box in Javascript
  • Opening a REMOTE WINDOW in Javascript
  • OPEN and WRITE a Data File in Perl
  • OPEN and READ a Data File in Perl
  • Mimic Typing from a Textfield in a Textarea with Javascript
  • Javascript Reset Form








  • Perl Programming - Javascript Programming - HTML Code - Mac Unix Command Line - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006-2009 iLoveTheCode.com


    Contact Chris | About this Site


    2210004
    Counter by iLoveTheCode.com


    Last Modified: Tuesday, 10-Feb-2009 02:34:16 EST



    Hosted as well :)
    Home-brewed logo - 1997