gpt4 book ai didi

javascript - removeClass 设置显示无

转载 作者:行者123 更新时间:2023-11-28 07:17:32 25 4
gpt4 key购买 nike

html:

<table>
<tr>
<td>Hi</td>
<td><a href="#">Click me</a>
</td>
</tr>
</table>

js:

$('td a').click(function (event) {
var txt = $(this);
event.preventDefault();
txt.closest('td').addClass('info');
txt.closest('td').fadeOut(500, function () {
txt.closest('td').removeClass('info');
});
this.blur();
txt.parent().attr('style', 'display: inherit;');
return false;
});

https://jsfiddle.net/iScripters/0dpLyv96/4/

当您单击“单击我”时,我希望将类“info”添加到父级 (td),然后使用淡出将其删除。相反,它会删除整个 .有什么解决方案或解决方法吗?

最佳答案

在代码中,removeClass 并没有设置 display:None,而是淡出的功能,将 display 设置为 None。如果您不希望将其设置为显示为 None,并在一段时间后将其删除,请使用 setTimeOut 等函数。链接-http://www.sitepoint.com/jquery-settimeout-function-examples/

关于javascript - removeClass 设置显示无,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30689423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com