gpt4 book ai didi

javascript - 我想使用位置函数向#cart-total-remove 添加一个类,我尝试了很多方法但没有奏效

转载 作者:行者123 更新时间:2023-12-04 08:26:22 24 4
gpt4 key购买 nike

这是购物车成功功能

success: function(json) {
// Need to set timeout otherwise it wont update the total
setTimeout(function () {
$('#cart > button').html('<span id="cart-total-remove"><img src="http://localhost/nerv/image/catalog/icons/bag.png"/> ' + json['total'] + '</span>');
}, 100);

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
location = 'index.php?route=checkout/cart';
} else {
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
},
我尝试添加类更改删除以稍后对其进行样式设置
$(document).ready(function() {

if ( window.location.href == 'http://localhost/nerv/index.php?route=common/home' ){
$("#cart #cart-total-remove img").removeClass("change-remove");
} else {
$("#cart #cart-total-remove img").addClass("change-remove");
console.log(window.location.href);
}

});

这是我的 css 代码
#cart #cart-total-remove img {
filter: invert(1);
}
#cart #cart-total-remove img.change-remove{
filter: none;
}

任何帮助,将不胜感激

最佳答案

如果它可能有帮助,请尝试此操作。
您的 CSS 代码具有类 img.change-remove 您尝试添加的类(class)是 .change-remove ,因此它(你的 css)必须是:
注意 css 代码的变化img .change-remove 不是 img.change-remove

#cart #cart-total-remove img {
filter: invert(1);
}
#cart #cart-total-remove img .change-remove{
filter: none;
}

关于javascript - 我想使用位置函数向#cart-total-remove 添加一个类,我尝试了很多方法但没有奏效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65245002/

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