jQuery再次显示淡出元素

时间:2015-08-04 16:16:42

标签: jquery html

当页面上的Ajax调用完成时,我调用下面的代码行来隐藏处理消息。

j$('[id$="deleteActionStatusId"]').fadeOut();

但是当用户再次启动相同的Ajax调用时,我试图显示处理消息,如下所示,但它不会显示。

document.getElementById('deleteActionStatusId').innerHTML = "Processing...";

由于jQuery deleteActionStatusId调用,开发人员控制台显示display : none的样式属性设置为fadeOut。如何反转此过程,以便它也适用于下一个Ajax调用?

3 个答案:

答案 0 :(得分:1)

检查此示例:http://jsfiddle.net/kek06xu3/(刷新页面以尝试另一个)

$('[id$="deleteActionStatusId"]').fadeIn(); 

或使用:

$('[id$="deleteActionStatusId"]').show();

如果您希望再次淡入,请使用fadeIn()。如果您只是希望它显示(如弹出),您应该使用show()。此外,混合Javascript和jQuery看起来很奇怪,你应该避免它。您应该将整个代码更改为:

//Fade the element out
$('[id$="deleteActionStatusId"]').fadeOut();

//Select the element with id = deleteActionStatusId and change it to processing
$('#deleteActionStatusId').html("Processing");

//Make it show the element again
$('[id$="deleteActionStatusId"]').fadeIn();

您可以document.getElementById('deleteActionStatusId')而不是$('#deleteActionStatusId'),而是选择它。

答案 1 :(得分:0)

您需要调用%% --- 'Transform this in a function, for fun and profit' %'Input data' n = {'1', '2'; '5', '6'}; m = {'1', '2'; '3', '4'}; %'Process data' a = [n;m]; %'All' u = cell(size(a)); %'Unique' ku = 1; %'Unique counter' u(ku,:) = a(1,:); %'Add first row' %'Add only rows that do not exist in u' for ia = 2:size(a,1) found = false; %'search flag' for iu = 1:ku if all(strcmp(a(ia,:), u(iu,:))) %'row is already registered' found = true; break; end; end; if ~found %'add row' ku = ku+1; u(ku,:) = a(ia,:); end; end; u = u(1:ku,:); %'Trim unused space in u' %'Sorting the unique rows in alpabetical order is left as exercise' 方法,如下所示:

fadeIn()

jQuery fadeIn method documentation

答案 2 :(得分:0)

以下行不会移除display:none事件设置的.fadeOut()

document.getElementById('deleteActionStatusId').innerHTML = "Processing...";

您可以使用以下技术之一再次显示您的内容。

j$('[id$="deleteActionStatusId"]').css({display: "block"});
j$('[id$="deleteActionStatusId"]').fadeIn();
j$('[id$="deleteActionStatusId"]').show();