1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Adding a spoiler to pages

Discussion in 'XenForo Questions and Support' started by Ferdinand, Nov 3, 2014.

  1. Ferdinand

    Ferdinand Active Member

    Hi is it possible to use xenforo code to add a spoiler to pages at the moment I'm using the code below however it's not ideal? Thanks in advance.
    HTML:
    <html>
    <head>
        <title>Year 1</title>
        <style type="text/css">
    body,input
        {
        font-family:"Trebuchet ms",arial;font-size:0.9em;
        color:#333;
        }
    .spoiler
        {
        border:1px solid #ddd;
        padding:3px;
        }
    .spoiler .inner
        {
        border:1px solid #eee;
        padding:3px;margin:3px;
        }
        </style>
        <script type="text/javascript">
    function showSpoiler(obj)
        {
        var inner = obj.parentNode.getElementsByTagName("div")[0];
        if (inner.style.display == "none")
            inner.style.display = "";
        else
            inner.style.display = "none";
        }
        </script>
    </head>
    <body>
    <h1>TEST</h1>
    <div class="spoiler">
        <input type="button" onclick="showSpoiler(this);" value="Show/Hide" />
        <div class="inner" style="display:none;">
        This is a spoiler!
        </div>
    </div>
    </body>
    </html>
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    A js solution like you have is what I would do. You have the functionality you want. What do you want to change about it? Maybe some styling?
     

Share This Page