0

我没有 JS 经验,我真的需要帮助。我有这个代码:

<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>

我需要使 div 消失的动作在 400 毫秒内延迟。

谢谢

4

1 回答 1

0

你可以这样做

<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>
于 2013-07-12T14:56:03.993 回答