我需要一个圆形进度指示器。如何实现?
我想要的是 jQuery UI 在他们的计划页面中所拥有的,但它还没有被实现。我只是好奇是否有人之前已经实现了它。请参见以下图片中的项目 6。
我需要一个圆形进度指示器。如何实现?
我想要的是 jQuery UI 在他们的计划页面中所拥有的,但它还没有被实现。我只是好奇是否有人之前已经实现了它。请参见以下图片中的项目 6。
比如说,像这样的加载动画?你不需要一个插件就能做到。只需根据需要使用 .show()
和 .hide()
来控制GIF的显示和隐藏(或将其插入到DOM中,取决于你的喜好)。
progressMeterSpriteCoords = [
{x: 0, y: 0}, //0%
{x: -16, y: 0}, //1%
{x: -32, y: 0}, //2%
... etc etc..
{x: -320, y: -0}, //19%
{x: 0, y: -16}, //20%
{x: -16, y: -16}, //21%
{x: -32, y: -16}, //22%
... etc etc..
{x: -320, y: -16}, //29%
... etc etc..
{x: -320, y: -320} //99%
]
<div id="loading"></div>
<a href="javascript:void(0);" id="load">Load!</a>
<script type="text/javascript">
$('#load').click(function(){ // click event on the load link
$('#loading').html('<img src="/path/to/animation.gif" />'); // display a loading animation where the content goes
$.get('/file/to/load.php', function(data) { // request content to be displayed
$('#loading').html(data); // display content
});
});
</script>
干杯
#load
的 href 应该是 /path/to/animation.gif
,并且在 $('#load').click(...)
中应该使用 event.preventDefault()
。这样,如果用户禁用了 JS,页面仍然能够有意义地工作。 - Peter Ajtai