Aytek
Aytek

Reputation: 224

Small JavaScript animation integration

I have some JavaScript code:

<script type="text/javascript">
  function hideshow(which) {
    if (!document.getElementById)
      return
    if (which.style.display=="block")
      which.style.display="none"
    else
      which.style.display="block"
  }
</script>

how can I integrate a .slideToggle(1000); animation this code?

Upvotes: 0

Views: 43

Answers (1)

Jafar Akhondali
Jafar Akhondali

Reputation: 1537

Display can't be animated, what you can do is combining it with opacity in css.
default css:

display:none;
opacity:0;
transition:1s opacity ease;
-webkit-transition:1s opacity ease;

JS:

 which.style.display="block"
 which.style.opacity="1"

Since you are new to javascript i didn't provide complete solution but you should've get the idea.

Upvotes: 1

Related Questions