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



  • Pass the Javascript, please...
    123,709

    iLoveTheCode.com
    Javascript > Javascript Tutorials > Javascript Change Background Colors

    Javascript Change Background Colors



    NOTE: If you copy and paste this code, watch out for spaces and line returns put in by the browser, like after the getElementById.

    <body id=hey>

    <a onMouseover=document.getElementById('hey').style.backgroundColor='red'> Make it Red!</a> ----
    <a onMouseover=document.getElementById('hey').style.backgroundColor='#99FFCC'> Make it Sort of Green!!!</a>


    -In our HTML body tag, we name our id attribute hey because we like short names.
    -We create two links that use the Javascript onMouseover event handler.
    ---After the equals sign:
    -----document - this page
    -----getElementById - Javascript's built-in method that will get elements from our page.
    -----In the parenthesis - we state that we will be working on the hey element of our page.
    -----We then call the Javascript style object.
    -----We then call the backgroundColor property of the style object.
    -----We say make it red for the first sentence, and using a hexidecimal number with the pound symbol, make it "off green" for the second.


    NOTES: We could have put the id=hey in a table tag and our table would change background colors, like so:

    <table id=hey height=50><tr><td valign=top height=50>
    <a onMouseover=document.getElementById('hey').style.backgroundColor='red'> Make it Red!</a> ----
    <a onMouseover=document.getElementById('hey').style.backgroundColor='#99FFCC'> Make it Sort of Green!!!</a>
    </td></tr></table>



    Free Copy and Paste Javascript Code:

    <body id=hey>

    <a onMouseover=document.getElementById('hey').style.backgroundColor='red'> Make it Red!</a> ----
    <a onMouseover=document.getElementById('hey').style.backgroundColor='#99FFCC'> Make it Sort of Green!!!</a>



    Resources:
    Javascript Change Fonts
    Javascript Change Font Size
    HTML paragraph tag
    Javascript onMouseover
    Javascript onClick
    If, Else If, and Else in Javascript
    Create a Function in Javascript
    Call your Function in Javascript
    Passing an Argument or Variable to a Javascript
    Increment a Variable in Javascript




    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Javascript Change Font Size
    Next Article: onClick Javascript





    CSS MasteryCSS Mastery

    Andy Budd, Simon C...

    New $23.85

    CSSCSS

    David McFarland

    New $23.09

    CSSCSS

    Eric Meyer

    New $29.69

    JavaScriptJavaScript

    David Flanagan

    New $31.49

    New Perspectives on HTML...New Perspectives on HTML and XHTML 5...

    Partrick Carey

    New $67.45

    Learning Web DesignLearning Web Design

    Jennifer Niederst ...

    New $26.99

    Bulletproof Web DesignBulletproof Web Design

    Dan Cederholm

    New $23.99

    HTMLHTML

    Gary B. Shelly, Th...

    New $84.55

    Dreamweaver CS3Dreamweaver CS3

    David McFarland

    New $29.69


    Of Interest:
  • Write a WHILE LOOP in Perl, Carefully
  • Finding the Length (Index Numbers) of an Array in Perl
  • Add to End of an Array with Push in Perl
  • To Reverse an Array in Perl
  • Javascript Reverse - Use Reverse on Items in an Array in Javascript
  • Make a String into a Link in Javascript
  • Javascript Redirect
  • Get Query String Using Javascript
  • HTML Frames
  • HTML Codes
  • HTML Color Chart
  • HTML Tags

  • More Articles:
  • Passing a Variable or Value to a Subroutine in Perl
  • Matching at the Beginning and End 2
  • Add to the Beginning of an Array with Unshift in Perl
  • Encryption with the Crypt Function in Perl
  • Javascript Change Fonts
  • Javascript Change Font Size
  • onClick Javascript
  • Javascript Alert
  • Javascript Concat - Use Concat to Join Two Arrays in Javascript
  • Increment a Variable in Javascript
  • Opening an Alert Box in Javascript
  • Use onClick in Javascript
  • HTML Tables
  • Make Text Bold Using HTML
  • HTML Subscript Text
  • HTML Tags

  • 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,470
    Counter by iLoveTheCode.com


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