TIME NOW
World current time now,
CALENDAR
Calendar monthly, yearly
login GOLD PRICE, RATE
login HOROSCOPE
login DICTIONARIES, LISTS
login SCIENCE EDUCATION RELIGION
login FINANCE, BUSINESS
login WORLD COUNTRIES, WIKI

HTML code examples, samples, tutorial

Previous articlePage bottomNext article  ALL TOPICS

Javascript example. Change content of DIV, and IMG element

 Mouse events:
onclick    
ondblclick    
onmousedown    
onmousemove    
onmouseover    
onmouseout    
onmouseup

Change text of DIV element. Events- onmouseout, onmouseover.
<html>
   <head>
    <style>
    body{
    text-align: center;
    }
    
    #a{
    width: 200px;
    height: 200px;
    background-color: yellow;
    text-align: center
    }
    </style>    
   </head>
   <body>
           <div id = "a" 
           onmouseover = "this.innerHTML = 'ANOTHER TEXT';" 
           onmouseout  = "this.innerHTML = 'TEXT';" >
           TEXT
           </div>
   </body>
</html>

Change content of DIV element. Events- onmouseoutonmouseover.
<html>
   <head>
    <style>
    body{
    text-align: center;
    }
    
    #a{
    width: 200px;
    height: 200px;
    background-color: yellow;
    text-align: center
    }

    </style>    
   </head>
   <body>
           <div id = "a" 
           onmouseover = "this.innerHTML = '<img src = smile_2.png >';" 
           onmouseout  = "this.innerHTML = '<img src =    smile_1.png >';" >
           <img src = "smile_1.png" >
           </div>
   </body>
</html>


Change source file of IMG element. Events- onmouseoutonmouseover.
<html>
   <head>
    <style>
    body{
    text-align: center;
    }
    
    #a{
    width: 200px;
    height: 200px;
    background-color: yellow;
    text-align: center
    }
    </style>    
   </head>
   <body>
           <div id = "a" >
           <img src = "smile_1.png" 
           onmouseover = "this.src = 'smile_2.png';" 
           onmouseout   = "this.src = 'smile_1.png';" >
           </div>
   </body>
</html>
 
Previous articlePage topNext article  ALL TOPICS



 Use username: Guest, Anonymous, Programmer






QUOTES:
If it were done when 'tis done, then 'twere well It were done quickly.
William Shakespeare
Our lives improve only when we take chances
and the first and most difficult risk we can take is to be honest with ourselves.
Few people are successful unless a lot of other people want them to be.
Charles Browder