Text change on mouseover?

Discussion in 'JavaScript' started by Puerto Rico, Aug 4, 2006.

  1. #1
    For example when the mouse is over a text like "EXAMPLE", a text in this case called "EXAMPLE 2" change to "EXAMPLE 3". Something similar to inner html, the difference is that you don't need to click. Excuse my english, I hope you can understand!:(
     
    Puerto Rico, Aug 4, 2006 IP
  2. [*-AnOnYmOuS-*]

    [*-AnOnYmOuS-*] Active Member

    Messages:
    253
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Its not that hard, but too bad Im not really gonna write the code but I will point out what you'll need to do.(BTW: this is only one way of doing it.)

    1. Put the text you want to change in a div tag.
    2. In this div tag add a "mouseover" element that calls a javascript function.
    3. Further on, in the javascript function, use a getelemetbyid to be able to write to it.
    4. With that value use it with getelementbyid(div tag id).innerhtml= "whatever text you want ;)".


    That should be it. :rolleyes: :D.
    Hope I helped..
     
    [*-AnOnYmOuS-*], Aug 5, 2006 IP
  3. Puerto Rico

    Puerto Rico Peon

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, but can you PLEASE write the code or post a link where I can find more info:)
     
    Puerto Rico, Aug 5, 2006 IP
  4. [*-AnOnYmOuS-*]

    [*-AnOnYmOuS-*] Active Member

    Messages:
    253
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Here this is a code I just wrote, added some unnecessary things..
    Hope I helped..
     
    [*-AnOnYmOuS-*], Aug 6, 2006 IP
  5. Puerto Rico

    Puerto Rico Peon

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thaaaaanks a lot!:)
     
    Puerto Rico, Aug 6, 2006 IP
  6. [*-AnOnYmOuS-*]

    [*-AnOnYmOuS-*] Active Member

    Messages:
    253
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #6
    No +rep =( . LOL just jokin although It wouldn't have been so hard :p . Glad I helped.
     
    [*-AnOnYmOuS-*], Aug 7, 2006 IP
  7. rmfreyre

    rmfreyre Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    go learn javascript, its not difficult; it'll save you time in the future, and won't make you look intellectually lazy; good luck papi.
     
    rmfreyre, Jun 17, 2011 IP
  8. unknownpray

    unknownpray Active Member

    Messages:
    3,831
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    70
    #8
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <head>
    <title>I can change text =) :p</title>
    <style type=text/css>
    div
    {
    font-family: Georgia
    }


    </style>
    </head>
    <body>
    <script type=text/javascript>
    function changetext()
    {
    var textchange2 = "This is the new me :p " ;
    var id = document.getElementById("DP");
    id.innerHTML=textchange2;
    }
    </script>
    <div id="DP" onmouseover="changetext();">Lets say this is text 1</div>
    </body>
    </html>
     
    unknownpray, Jul 15, 2011 IP