1 回答

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊
把它放在課堂transition上yellow。然后,在添加類之前,您需要稍微延遲一下以允許.red添加該類.yellow。50ms應(yīng)該足夠了。嘗試這個(gè):
$("td").click(function() {
var $td = $(this).addClass("red");
setTimeout(() => $td.addClass('yellow'), 50);
});
table { border-collapse: collapse; }
td {
border: solid black 1px;
height: 50px;
width: 50px;
cursor: pointer;
}
.red { background-color: red; }
.yellow {
background-color: yellow;
transition: background-color 1s ease-in-out;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr>
<td></td>
</tr>
</table>
- 1 回答
- 0 關(guān)注
- 161 瀏覽
添加回答
舉報(bào)