jquery - 有没有办法让我的类覆盖 jQuery 主题的类?

标签 jquery css jquery-ui

我对 jQuery 很陌生,并且对主题覆盖 CSS 类有疑问。

这是我的 HTML 代码:

<head>
  .clicked
  {
    text-decoration: line-through !important;
    color: #000000; 
  }
</head>
...
<div data-role="collapsible" data-theme="b" data-content-theme="b" data-collapsed icon="arrow-r" data-expanded-icon="arrow-d">
  <ul data-role="listview" id="Key"></ul>
</div>

这是我的 JS:

function WriteQuote(item) {
        $("#"+item).addClass(function(index, currentClass) {    
            if (currentClass.lastIndexOf("clicked") >= 0) {
                $("#"+item).removeClass("clicked");
                return; 
            }
            return "clicked";
        });
    }

我计划使用toggleClass,因此此代码仅用于测试目的。 在研究 Firebug 时,我发现 a.ui-link-inherit 是首选并适用:

a.ui-link-inherit {
    text-decoration: none !important;
}
.clicked {
    color: #000000;
    text-decoration: line-through !important;
}

有没有办法让我的类覆盖 jQuery 主题的类? 我的目标是当用户单击给定的 ListView 元素时切换“直通”。

最佳答案

主题的 CSS 规则适用,因为它比您的更具体。解决方案是为您的规则添加更多特异性。

a.ui-link-inherit.clicked {
    color: #000000;
    text-decoration: line-through !important;
}

演示:http://jsfiddle.net/wryE5/

关于jquery - 有没有办法让我的类覆盖 jQuery 主题的类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14075730/

相关文章:

jquery - jQuery(function($) { ... }) 是什么意思?

jquery - 文本根据元素内容淡出

图像加载时的 jQuery 回调(即使图像被缓存)

javascript - 如果该元素曾经被隐藏,我的 jQuery UI 日期选择器将不会显示

css - 带有 :before and :after 的背景图像

html - Primefaces 菜单栏右对齐子菜单

javascript - 从单独页面加载的 JQuery UI 对话框中的 Google 图表

javascript - 如果输入错误,HTML 输入类型日期有时为空值

javascript - 如何在不刷新页面或更改 url 的情况下加载不同的 html 页面?

javascript - 我如何更改此代码,使其从白色>绿色>黑色?