这并不严格地具有撤消按钮,但是我有灰色的功能并在点击时穿出物品。当再次点击时,我想让灰色和交叉线恢复正常(黑色而不是交叉)。 https://codepen.io/HelleFl/pen/OjNQop撤消功能不起作用
$(".item").click(function() {
$(this).css("text-decoration", "line-through");
$(this).css("color", "gray");
if ($(this).css('color', 'gray') {
$(this).click(function() {
$(this).css('color', 'black');
$(this).css('text-decoration', 'none');
})
});
我似乎无法弄清楚,并codepen告诉我检查了分号。
不要这样做。不要在另一个绑定中嵌套绑定。相反,在顶级绑定中执行条件。同时使样式改变可以添加/删除的类大大减少了问题的范围。 – Taplar
请问您能详细说明一下吗?因此,将函数内部的UNDO函数嵌套到DO中,而不是将IF函数完全分开? – Helle