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

ehr*_*etf 2 css jquery 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>
Run Code Online (Sandbox Code Playgroud)

这是我的JS:

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

我打算使用toggleClass,所以这段代码仅用于测试目的.在查看Firebug时,我发现这a.ui-link-inherit是首选并适用:

a.ui-link-inherit {
    text-decoration: none !important;
}
.clicked {
    color: #000000;
    text-decoration: line-through !important;
}
Run Code Online (Sandbox Code Playgroud)

有没有办法让我的类覆盖jQuery主题的类?我的目标是在用户点击给定的listview元素时切换"直通".

JJJ*_*JJJ 5

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

a.ui-link-inherit.clicked {
    color: #000000;
    text-decoration: line-through !important;
}
Run Code Online (Sandbox Code Playgroud)

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