NEWS: Total Picture Views: 151536 | Total Article Views: 161036 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. PickUpThings with Becker Robot | 3. How to read a JSON and work with it | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

OnClick, OnMouseOver and OnMouseOut Example Javascript


In this example I will be showing you how to use OnClick, OnMouseOver and OnMouseOut.


<!DOCTYPE html>
<head lang="en">
    <meta charset="UTF-8">
            background-color: #00ffff;

            background-color: darkgreen;
            color: pink;
    <h1 onclick="clickH1()" id="h1">This is heading 1</h1>
    <h2 onclick="ClickH2()" id="h2">This is heading 2</h2>

    <h3>Table Demo</h3>
<table border="1">
        <td class="row1" id="1" onclick="onClickTable(1)">Row 1</td>
        <td class="row1" id="2" onclick="onClickTable(2)">Row 1</td>
        <td class="row1" id="3" onclick="onClickTable(3)">Row 1</td>
        <td id="4" onclick="onClickTable(4)">Row 2</td>
        <td id="5" onclick="onClickTable(5)">Row 2</td>
        <td id="6" onclick="onClickTable(6)">Row 2</td>
        <td id="7" onclick="onClickTable(7)">Row 3</td>
        <td id="8" onclick="onClickTable(8)">Row 3</td>
        <td id="9" onclick="onClickTable(9)">Row 3</td>

<strong>This is an image</strong>
<br><img src="//" onmouseover="resizeImage()" onmouseout="imageOut()" height="100px" width="100px" id="image">
<p id="p">This is a paragraph</p>
<a href="index.html">Click me</a>

<script type="text/javascript">
    function resizeImage(){
        var h = document.getElementById("image").height;
        var w = document.getElementById("image").width;

        document.getElementById("image").style.height = (h * 2) + "px";

        document.getElementById("image").style.width = (w *  2) + "px";

    function imageOut(){
        document.getElementById("image").style.height = 100 + "px";

        document.getElementById("image").style.width = 100 + "px";

    function clickH1(){
        document.getElementById("h1").style.backgroundColor = "#000077";
        document.getElementById("h1").style.color = "yellow";

    function ClickH2(){
        document.getElementById("p").style.backgroundColor = "#000077";
        document.getElementById("p").style.color = "yellow";

    function onClickTable(x){
        document.getElementById(x).style.display = "none";
Attachments: None

Tags: OnClick OnMouseOver OnMouseOut

Total Views: 966

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 02/25/15


Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.