Javascript 如何在jquery代码中添加fadein效果

Javascript 如何在jquery代码中添加fadein效果,javascript,jquery,gridview,Javascript,Jquery,Gridview,我想知道怎么把fadeIn代码放在这里?我在gridview中有一个gridview,我想在用户单击“加减”图片时在其中添加一个效果,到目前为止,我的效果只是通过gridview的一个简单弹出窗口,如何将fadeIn或slideDown效果添加到我的代码中 下面是我的代码 $("[src*=plus]").live("click", function() { $(this).closest("tr").after("<tr><td></td><t

我想知道怎么把fadeIn代码放在这里?我在gridview中有一个gridview,我想在用户单击“加减”图片时在其中添加一个效果,到目前为止,我的效果只是通过gridview的一个简单弹出窗口,如何将fadeIn或slideDown效果添加到我的代码中

下面是我的代码

$("[src*=plus]").live("click", function() {
    $(this).closest("tr").after("<tr><td></td><td colspan ='100%'>" + $(this).next().html() + "</td></tr>");
    $(this).attr("src", "../Images/Icons/minus2.png");
});
$("[src*=minus]").live("click", function() {
    $(this).attr("src", "../Images/Icons/plus2.png");
    $(this).closest("tr").next().remove();
});
$(“[src*=plus]”。实时(“单击”,函数(){
(“+$(this).next().html()+”)之后的“$”;
$(this.attr(“src”,“./Images/Icons/minus2.png”);
});
$(“[src*=减号]”).live(“单击”,函数(){
$(this.attr(“src”,“./Images/Icons/plus2.png”);
$(this).closest(“tr”).next().remove();
});

这将最初隐藏内容,允许您使用
fadeIn()

$(“[src*=plus]”。实时(“单击”,函数(){
var container=$(this),
newContent=$(“”+$(this.next().html()+“”).hide();
容器。之后(新内容);
newContent.fadeIn();
$(this.attr(“src”,“./Images/Icons/minus2.png”);
});
$(“[src*=减号]”).live(“单击”,函数(){
$(this.attr(“src”,“./Images/Icons/plus2.png”);
$(this).closest(“tr”).next().fadeOut(函数(){
$(this.remove();
});
});

这将最初隐藏内容,允许您使用
fadeIn()

$(“[src*=plus]”。实时(“单击”,函数(){
var container=$(this),
newContent=$(“”+$(this.next().html()+“”).hide();
容器。之后(新内容);
newContent.fadeIn();
$(this.attr(“src”,“./Images/Icons/minus2.png”);
});
$(“[src*=减号]”).live(“单击”,函数(){
$(this.attr(“src”,“./Images/Icons/plus2.png”);
$(this).closest(“tr”).next().fadeOut(函数(){
$(this.remove();
});
});

如果立即将display:none添加到生成的元素中,则应该能够淡入淡入。要淡出,您需要在淡出函数中使用回调来删除元素,这样在删除元素之前,它就有时间进行转换*根据需要进行修改,使行淡入淡出,而不是图像

$("[src*=plus]").live("click", function () {
      $(this).closest("tr").after("<tr style='display:none;'><td></td><td colspan ='100%'>" + $(this).next().html() + "</td></tr>");
      $("tr[style*='display:none']").fadeIn(500);
      $(this).attr("src", "../Images/Icons/minus2.png");
});

$("[src*=minus]").live("click", function () {
      $(this).attr("src", "../Images/Icons/plus2.png");
      var removedTr = $(this).closest("tr").next();
      removedTr.fadeOut(500, function(){
         removedTr.remove();
      });
});
$(“[src*=plus]”。实时(“单击”,函数(){
(“+$(this).next().html()+”)之后的“$”;
$(“tr[style*='display:none']);
$(this.attr(“src”,“./Images/Icons/minus2.png”);
});
$(“[src*=减号]”).live(“单击”,函数(){
$(this.attr(“src”,“./Images/Icons/plus2.png”);
var removedTr=$(this.closest(“tr”).next();
removedTr.fadeOut(500,函数(){
removedTr.remove();
});
});

如果立即将display:none添加到生成的元素中,则应该能够淡入淡入。要淡出,您需要在淡出函数中使用回调来删除元素,这样在删除元素之前,它就有时间进行转换*根据需要进行修改,使行淡入淡出,而不是图像

$("[src*=plus]").live("click", function () {
      $(this).closest("tr").after("<tr style='display:none;'><td></td><td colspan ='100%'>" + $(this).next().html() + "</td></tr>");
      $("tr[style*='display:none']").fadeIn(500);
      $(this).attr("src", "../Images/Icons/minus2.png");
});

$("[src*=minus]").live("click", function () {
      $(this).attr("src", "../Images/Icons/plus2.png");
      var removedTr = $(this).closest("tr").next();
      removedTr.fadeOut(500, function(){
         removedTr.remove();
      });
});
$(“[src*=plus]”。实时(“单击”,函数(){
(“+$(this).next().html()+”)之后的“$”;
$(“tr[style*='display:none']);
$(this.attr(“src”,“./Images/Icons/minus2.png”);
});
$(“[src*=减号]”).live(“单击”,函数(){
$(this.attr(“src”,“./Images/Icons/plus2.png”);
var removedTr=$(this.closest(“tr”).next();
removedTr.fadeOut(500,函数(){
removedTr.remove();
});
});

噢,哎呀,对不起,我把javascript和jquery的连接搞错了。更新了上面剪下的图片!它必须是.css而不是.style,我的错。样式是常规javascript,需要不同的语法。它可以工作,但图像是淡入的样式。里面没有gridview。Lolfred的解决方案是有效的——我不知道你想得到的是tr,而不是图像,不过这是有道理的。更新了我的解决方案来反映这一点。威尔和愤怒,谢谢!它起作用了!非常感谢你!投票赞成!哦,哎呀,对不起,我把javascript和jquery连接起来了。更新了上面剪下的图片!它必须是.css而不是.style,我的错。样式是常规javascript,需要不同的语法。它可以工作,但图像是淡入的样式。里面没有gridview。Lolfred的解决方案是有效的——我不知道你想得到的是tr,而不是图像,不过这是有道理的。更新了我的解决方案来反映这一点。威尔和愤怒,谢谢!它起作用了!非常感谢你!投票赞成!查看涉及
newContent
的更改查看涉及
newContent
的更改注意:没有必要编辑您的问题标题来表示“已解决”-只需接受最有用的答案,并将其保留在那里。请使用
。on
作为
。live
已弃用。注意:没有必要编辑您的问题标题来表示“已解决”“已解决”-只需接受最有用的答案,并将其保留。请使用
.on
,因为
.live
已被弃用。