如何使用jQuery显示隐藏元素 [英] How to show a hidden element with jQuery

查看:71
本文介绍了如何使用jQuery显示隐藏元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有一个忙碌的图标,其类别为隐藏".当用户单击按钮开始处理输入数据时,我要显示忙碌图标.我正在用

I have a busy icon on my page which has a class of "hidden". When the user clicks a button to start processing input data, I want to show the busy icon. I am doing this with

$("#busy").removeClass("hidden");

在删除隐藏类之后,我立即使用AJAX从服务器获取一些数据,将其显示在页面上,然后将隐藏类添加回繁忙的图像中.

Immediately after removing the hidden class, I use AJAX to get some data from the server, display it on the page and add the hidden class back to the busy image.

我的问题是,忙碌的图标永远不会显示.我不是javascript/jQuery专家,但我认为这是因为直到脚本执行完毕后页面才会重绘?

My problem is that the busy icon is never displayed. I'm not a javascript/jQuery expert but I think this is because the page isn't redrawn until after the script has finished executing?

在进行AJAX处理时如何显示忙碌图标?

How can I get the busy icon to display while the AJAX processing is in progress?

推荐答案

尝试一下

首先在div上链接您的图片

First u link ur image on a div

然后

尝试一下,它将正常工作

Try this, it will work fine

$.ajax({
   url : "URL",
   data: { data },
   beforeSend: function(){
     $("#loading").show();
   },
   complete: function(){
     $("#loading").hide();
   },
   success:  function (response) {

   });
});

这篇关于如何使用jQuery显示隐藏元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆