2012-08-07 67 views
-1

也许我应该问这样早些时候一个div ...jQuery来显示被隐藏的CSS

我有一个加载从SQL表中的所有项目核实。然后我有一些复选框将用于按颜色过滤,所以如果用户选择BLUE,则DIV将重新加载,通过蓝色作为颜色并仅显示蓝色项目。

一旦用户点击,我想在加载蓝色项目的时间内显示“加载”.gif。也许这是超短期或许需要3秒左右......

我的选择是:

  • 有我的主DIV内的另一个DIV包含.gif和CSS是不显示的。然后用一个JQUERY,我将不得不显示它,然后隐藏它......如果这个选项是好的,我可以使用什么样的JQUERY?

  • 使用jQuery来.load装车DIV之前,我过滤

感谢后,装载的结果!

+1

看一看的[BlockUI ](http://www.malsup.com/jquery/block/#page)jQuery插件。 – Bill 2012-08-07 17:11:05

回答

1

最简单的方法是让DIV在网页中,通常接近页面的底部,隐藏着的CSS:

<div id="loading"> 
    <img src="img/loading.gif" alt="Loading." /> 
</div> 

CSS:

#loading { 
    display:none; 
    /* some more code to position the div where you want */ 
} 

JS:

$("#loading").toggle(); // or .show()/.hide() 

查看小提琴:http://jsfiddle.net/Gwmah/

0

有几个提供b jQuery的有用的功能,以显示html元素

  • 隐藏()显示()
  • 肘节()

    //your css would be like this 
    #divToDisplay { 
        display:none; 
    } 
    
    $('document').ready(function() { 
    
        $('#divToDisplay').show(); 
    }); 
    
    //or to make it show hide on click use toggle() 
    $('document').ready(function() { 
    
        $('#divToDisplay').toggle(); 
    }); 
    
    //you can also use slideToggle() to give some animation for show and hide 
    $('document').ready(function() { 
    
        $('#divToDisplay').slideToggle("slow"); 
    }