문제

I have got no experience in JS and I really need help. I have this code:

<script type="text/javascript">
var showElem;
showElem = function( showID ) {
   div = (( document.getElementById ) ? document.getElementById( showID ) : document.all[    showID ] );
   try {
   div.className = (( div.className === "hide" ) ? "show" : "hide" );
   } catch( e ) {
   div.style.display = (( div.style.display === "none" ) ? "block" : "none" );
   }
};
</script>

I need the action that make the div disappear to be delayed in 400 milliseconds.

Thanks

도움이 되었습니까?

해결책

You could do it this way

<script type="text/javascript">
var showElem;
showElem = function( showID ) {
     div = (( document.getElementById ) ? document.getElementById( showID ) : document.all[    showID ] );
   try {
     setTimeout(function() {
         div.className = (( div.className === "hide" ) ? "show" : "hide" );
     }, 400)
   } catch( e ) {
       div.style.display = (( div.style.display === "none" ) ? "block" : "none" );
   }
};
</script>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top