jQuery if css = value then

标签 jquery css if-statement

我正在使用 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/

相关文章:

IF 语句上的 jQuery CSS 更改

if-statement - 检查空格键是否相等?

ruby-on-rails - 如何在 Rails ActiveRecord 中的日期指定小于今天的条件

jquery - 如何动态调整组织结构图定位

Javascript match() 正则表达式检测 URL 并链接到嵌入内容

javascript - 如何使用 Velocity.js 动画化翻译属性?

html - 自定义复选框在选中时会轻微移动

javascript - 如何在非 DOM 相关的对象及其属性上使用 jQuery 事件?

javascript - IE 问题 :visible?

CSS repeat-x 仅用于最右边的像素行