我正在使用 jQuery 在悬停某个菜单项时将一类 .display-product-noms 添加到 div。一旦触发,我就希望出现一个横幅,但前提是前一个类已添加到 div,所以我尝试使用以下内容:
if ($('.display-product-noms').css('left') === '16.4em!important') {
$('.nav-banner').css( "left", "41em!important" );
}
但没有任何反应,横幅以其原始值 left: -9999em 保持在 View 之外; 谁能阐明我哪里出错了?
最佳答案
http://jsfiddle.net/jadpLq73/1/
if ($('.product').css('left') == '10px') {
alert($('.product').css('left'))
$('.otherProd').css( "left", "10px", 'important');
}
另请阅读:https://stackoverflow.com/a/8894528/3556874
div.style('color', 'blue', 'important');
这样你就可以定义!important
优先级
关于jQuery if css = value then,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27924677/