executing a code by mouse click

Discussion in 'JavaScript' started by asmon, Feb 25, 2008.

  1. #1
    I need to run a code when i click on a text and i need the same text
    to disappear when i click on it.
    i know almost nothing about JS, is it possible doing that?

    ty.
     
    asmon, Feb 25, 2008 IP
  2. mjamesb

    mjamesb Member

    Messages:
    88
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    48
    #2
    <div id="mytext" style="display:;" onclick="this.style.display='none'">My Text</div>

    or to call external function

    <div id="mytext" style="display:;" onclick="HideMe()">My Text</div>

    <script language="javascript">
    function HideMe()
    { document.getElementById("mytext").style.display = 'none'; }
    </script>
     
    mjamesb, Feb 25, 2008 IP
  3. Lisans

    Lisans Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <div id="mytext" style="display:block;" onclick="this.style.display='none';">My Text</div>
     
    Lisans, Feb 25, 2008 IP