iLTC Home
Bookmark iLTC!
iLTC Google Boards

Google Groups
Receive The Code in Email!



Categories

Perl
  • Perl Tutorials Beginners

    Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

    HTML
  • HTML Tutorials



  • I bookmarked this site...
    123,737

    iLoveTheCode.com
    Javascript > Javascript Tutorials How To Easy > Use innerHTML to Change Text on a Page

    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="javascript:goHo()" onMouseOut="javascript:hu.innerHTML='Goodbye'">Say Hi</a>


    -We used the id tag to name our paragraph hu
    -We created our function and named it goHo because it's easy to type.
    -We used our hu name 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="javascript:goHo()" onMouseOut="javascript: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


    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Focus a Window with self.focus in Javascript
    Next Article: Get Query String Using Javascript





    CSSCSS

    Eric Meyer

    New $29.69

    Bulletproof Web DesignBulletproof Web Design

    Dan Cederholm

    New $23.99

    Head First HTML with CSS...Head First HTML with CSS & XHTML

    Eric Freeman, Elis...

    New $23.99

    CSSCSS

    David McFarland

    New $23.09

    HTML & XHTMLHTML & XHTML

    Chuck Musciano, Bi...

    New $29.99

    JavaScriptJavaScript

    David Flanagan

    New $31.49

    HTMLHTML

    Gary B. Shelly, Th...

    New $84.55

    HTML, XHTML, and CSS, Si...HTML, XHTML, and CSS, Sixth Edition ...

    Elizabeth Castro

    New $23.09

    Dreamweaver CS3Dreamweaver CS3

    David McFarland

    New $29.69


    Of Interest:
  • Exit a Loop with Last
  • Putting Two Strings Together, Concatenate
  • Create an Array of Specific Numbers in Perl
  • Redirect to a Different URL in Perl
  • Setting a Cookie using Javascript
  • Javascript Shift - Use Shift to Remove Items from the Beginning of an Array in Javascript
  • Javascript Subscript Text
  • Javascript Slice - Use Slice to Get Items from an Array in Javascript
  • HTML Body Tag
  • HTML Title Tag
  • HTML Font Code
  • Make Strikethrough Text Using HTML

  • More Articles:
  • To Reverse an Array in Perl
  • Substitute in Perl
  • Making a Directory Using mkdir in Perl
  • Renaming a File with Perl's RENAME Function
  • onClick Javascript
  • Increment a Variable in Javascript
  • Setting a Cookie using Javascript
  • Match with a Regular Expression, REGEX, in Javascript
  • Reading Cookies using Javascript
  • HTML Title Tag
  • HTML Center
  • HTML Color Codes
  • HTML Subscript Text

  • Search iLTC w/ Google





    Recent Articles

  • Javascript Focus Form Field
  • Javascript Lowercase Text
  • Javascript Uppercase Text
  • Javascript Superscript Text
  • Javascript Subscript Text
  • Make Text Blink Using Javascript
  • Make a String into a Link in Javascript
  • Javascript Italics Text
  • Javascript Bold Text
  • Javascript Redirect
  • HTML Frames
  • HTML Color Chart
  • HTML Link
  • Javascript Status Bar








  • Perl Programming - Javascript Programming - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006 iLoveTheCode.com


    Contact Chris | About this Site


    420,498
    Counter by iLoveTheCode.com


    Last Modified: Friday, 23-Jun-2006 07:23:17 EDT