Results 1 to 4 of 4

Thread: html spoiler code?

  1. #1
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Question html spoiler code?

    I've been looking for what I would term as a spoiler tag. What I want it to see a link that says "View Hidden Text" or something to that effect and when you click on it, then the hidden text appears (wether it be inline or in a popup windows doesn't matter too much to me).

    All the searching just leads me to code that works in forums. I actually have a spoiler code setup in my forums at G4TV. Look at the example of what I mean See where it says: Spoiler Alert: click to view --> Show

    I want this but just for a website.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    A common way of doing that is just to make the text the same color as the background. Often, both are slightly different than the page's background so you can see the div outline.

    Alternatively you'd need to show/hide the text or div using Javascript.
    el.style.display = 'none'; //hide
    el.style.display = 'block'; //normal, for a div

    Just use if statements to check which it is at the moment and switch it. Use onclick events to make it work.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Talking

    I found a good way of doing what I want to do. Here is the code.

    HTML Code:
    <script type="text/javascript" 
    
    src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min
    
    .js"></script>
    <script type="text/javascript">
    function toggleDiv(divId) {
       $("#"+divId).toggle();
    }
    </script>
    
    
    
    <a href="javascript:toggleDiv('myContent');" style="background-
    
    color: #ccc; padding: 5px 10px;">Toggle Button</a>
    <div id="myContent" style="background-color: #aaa; padding: 5px 
    
    10px;">
    The content in this div will hide and show (toggle) when the 
    
    toggle is pressed. 
    </div>

  4. #4
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the code. I just copied the script and it works fine.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •