1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Javascript HELP!!!

Discussion in 'JavaScript' started by roflcopter, Sep 8, 2007.

  1. #1
    <div onclick="document.getElementById('below').style.display = 'block'; ">
    <a href="javascript: void(0)">This is some text. Click here to show more text.</a>
    </div>
    
    <div id="below" style="display:none; ">
    This is some more text. You cannot see it on page load, click the text above to display it.
    </div>
    Code (markup):
    Is there a way when i press the 'this is some...' text; and when i press it again it retreats to its original state?
     
    roflcopter, Sep 8, 2007 IP
  2. ScubaAddict

    ScubaAddict Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <script type="text/javascript">
    function toggleBlock(id) {
    if (document.getElementById(id).style.display == 'none') {
    document.getElementById(id).style.display = 'block';
    } else {
    document.getElementById(id).style.display = 'none';
    }
    }
    </script>
    <div>
    <a href="javascript:void(0)" onClick="toggleBlock('below');">This is some text. Click here to show more text.</a>
    </div>
    
    <div id="below" style="display:none; ">
    This is some more text. You cannot see it on page load, click the text above to display it.
    </div>
    
    Code (markup):
     
    ScubaAddict, Sep 8, 2007 IP
  3. ScubaAddict

    ScubaAddict Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    or better?

    
    <script type="text/javascript">
    function toggleBlock(id, linkid) {
    if (document.getElementById(id).style.display == 'none') {
    document.getElementById(id).style.display = 'block';
    document.getElementById(linkid).innerHTML = 'HIDE TEXT'
    } else {
    document.getElementById(id).style.display = 'none';
    document.getElementById(linkid).innerHTML = 'Click here to show more text.'
    }
    }
    </script>
    <div>
    This is some text. <a href="javascript:void(0)" onClick="toggleBlock('below', 'linkid');" id="linkid">Click here to show more text.</a>
    </div>
    
    <div id="below" style="display:none; ">
    This is some more text. You cannot see it on page load, click the text above to display it.
    </div>
    
    Code (markup):
     
    ScubaAddict, Sep 8, 2007 IP
  4. roflcopter

    roflcopter Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks!!!!!!!!!!!!!!!
     
    roflcopter, Sep 8, 2007 IP