0

I fund a toggle effect that works perfectly, but I'd like to add a speed effect to slow it down a bit.

<script language="javascript" type="text/javascript">
    // <![CDATA[
    function toggle() {
        var ele = document.getElementById("toggleText");
        var text = document.getElementById("displayText");
        if (ele.style.display == "block") {
            ele.style.display = "none";
            text.innerHTML = "voir";
        } else {
            ele.style.display = "block";
            text.innerHTML = "fermer";
        }
    }
        // ]]>

    </script>

        <p><a id="displayText" href="javascript:toggle();" >voir</a> &lt;= click</p>
        <div id="toggleText" style="display: none;">
            <p>Yes!</p>
        </div>

Any idea how should I insert a speed value on it? It could be this or another piece of code, (I don't mind, as far as it does the job !) thanks !

JinSnow
  • 1,553
  • 4
  • 27
  • 49
  • Why not use [jQuery.toogle()](http://api.jquery.com/toggle/)? Just `$('#mydiv').toogle('slow')` then. – Alex Mar 22 '13 at 19:03
  • @Alex - maybe because he's not using jQuery? – j08691 Mar 22 '13 at 19:04
  • I know that, I'm just suggesting it in case he doesn't know about it - notice I just made a comment, not an answer. – Alex Mar 22 '13 at 19:05
  • Define `speed` please – Sebas Mar 22 '13 at 19:16
  • Indeed I am not using jQuery, because I didn't manage to add jQeury to my joomla website so I stick to javascript. By speed I meant something like a slideDown effect, something smoother than just a hide and show effect. – JinSnow Mar 22 '13 at 19:30
  • but all you're doing is to show and hide, what kind of slideDown do you want to do? Blend/fade ? – Sebas Mar 22 '13 at 22:25

1 Answers1

0

Use jQuery-UI toggle, has speed among other things:

http://api.jqueryui.com/toggle/

Tomer Arazy
  • 1,833
  • 10
  • 15
  • thanks a lot for your reply ! For some reason I did not manage to insert jQuery directly in joomla article, that's why I m trying to complete this code that already works (quick but at least it works !) – JinSnow Mar 22 '13 at 19:12