jQuery:FadeOut不适用于表行 [英] jQuery :FadeOut not working with table Rows
问题描述
我在浏览器中呈现了以下HTML表.我是通过ASP.NET代码隐藏文件创建此表的.
I have the following HTML table is rendered to my browser.I am creating this table from my ASP.NET codebehind file.
<table Class="tblTradeInCart">
<tr class="tblCartHeader">
<td>Item</td>
<td>Model</td>
<td> Price</td>
<td>Delete</td>
</tr>
<tr id="tr_15_1">
<td><img src="dia/images/LGVX9700.jpg" width="50" height="50" /></td>
<td>LG VX9700</td>
<td>$ 122</td>
<td><a href='#' onclick="deleteItem(15,1,'tr_15_1')"><img src='..\Lib\images\NCcross.gif' style='border:0px'></a></td>
</tr>
<tr id="tr_11_8">
<td><img src="dia/images/NOK5610.jpg" width="50" height="50" /></td>
<td>NOKIA 5610</td>
<td>$ 122</td>
<td><a href='#' onclick="deleteItem(11,8,'tr_11_8')"><img src='..\Lib\images\NCcross.gif' style='border:0px'></a></td>
</tr>
<tr id="tr_14_9">
<td><img src="dia/images/NOKN95.jpg" width="50" height="50" /></td>
<td>NOKIA N95</td>
<td>$ 91.5</td>
<td><a href='#' onclick="deleteItem(14,9,'tr_14_9')"><img src='..\Lib\images\NCcross.gif' style='border:0px'></a></td>
</tr>
</table>
并且在我的JavaScript中,我具有以下删除功能
and In my javascript i have the delete function as follows
function deleteItem(modelId,itemindexId, rowId)
{
$.get("RemoveFromCart.aspx",{ model:modelId,cartItem:itemindexId,mode:"removefromcart",rand:Math.random() } ,function(data)
{
//document.getElementById(rowId).style.display = "none";
var row=$("#"+rowId);
row.fadeOut(1000);
});
}
但是当我调用deleteItem函数时,我没有得到淡入淡出的效果. 隐藏像display ="none"这样的行.
But when i call the deleteItem function, I am not getting the fading Effect.Its simply hiding the row like the display="none".
任何人都可以指导我如何解决此问题吗?
Can any one guide me how to fix this ?
推荐答案
隐藏trs
时jQuery中存在问题.这是当前的解决方法,直到他们决定做出类似的事情为止.
There is a problem in jQuery when hiding trs
. This is the current workaround until they do something similar in the core, if they decide to.
row.find("td").fadeOut(1000, function(){ $(this).parent().remove();});
这基本上将tds
隐藏在行中,而不是实际行中.然后将其从DOM中删除.我相信它可以在所有浏览器中使用.如果需要,您可以专门针对IE.
This basically hides the tds
in the row, instead of the actual row. Then it removes the row from the DOM. It works in all browsers I believe. You could target IE specifically though if needed.
这篇关于jQuery:FadeOut不适用于表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!