Javascript 我想用location功能向#cart total remove添加一个类,我尝试了很多方法,但没有';行不通
这是购物车成功功能Javascript 我想用location功能向#cart total remove添加一个类,我尝试了很多方法,但没有';行不通,javascript,html,css,json,ajax,Javascript,Html,Css,Json,Ajax,这是购物车成功功能 success: function(json) { // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart > button').html('<span id="cart-total-remove"><i
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');
}
},
这是我的css代码
#cart #cart-total-remove img {
filter: invert(1);
}
#cart #cart-total-remove img.change-remove{
filter: none;
}
如果有任何帮助,我们将不胜感激。如果可能的话,试试这个。 您的CSS代码具有类img.change remove,并且您尝试添加的类是。change remove,因此它(您的CSS)必须是: 注意img.change remove而不是img.change remove的css代码中的更改
#cart #cart-total-remove img {
filter: invert(1);
}
#cart #cart-total-remove img .change-remove{
filter: none;
}
在这里检查您的两个条件是否有效
$(document).ready(function() {
if ( window.location.href == 'http://localhost/nerv/index.php?route=common/home' ){
$("#cart-total-remove img").removeClass("change-remove");
} else {
$("#cart-total-remove img").addClass("change-remove");
console.log(window.location.href);
}
});
我试过了,没用,不过还是谢谢你。
$(document).ready(function() {
if ( window.location.href == 'http://localhost/nerv/index.php?route=common/home' ){
$("#cart-total-remove img").removeClass("change-remove");
} else {
$("#cart-total-remove img").addClass("change-remove");
console.log(window.location.href);
}
});