现在,这看起来很简单,但我不知道它为什么不起作用。 我有一个HTML文件名g.html,其中包括jquery,jquery ui,jquery touch punch。 还包括g.js. 现在,在g.js里面使用jquery来动态修改元素的类。 为元素添加了一个新类。 从输出HTML代码可以看出:
<td class=" ui-datepicker-days-cell-over currentDay ui-datepicker-current-day ui-datepicker-today" data-handler="selectDay" data-event="click" data-month="11" data-year="2013"><a class="ui-state-default ui-state-highlight ui-state-active" href="#">26</a></td>
“currentDay”是我想要的课程,现在又添加了。 无论如何,我在g.html中有一个关于currentDay的css,其中说:
.currentDay {
background-image:url('tick.jpg');
background-repeat:repeat-x;
font-weight: bold;
color:#ad5;
border: 1px solid #aaa;
}
但这款造型根本没有应用? 怎么了?我该怎么办?
答案 0 :(得分:3)
在!important
课程中使用.currentDay
关键字。
如果在同一元素上也存在任何其他样式,则!important
规则会始终应用您的样式。在您的情况下,有许多类将currentDay
类应用于同一元素。优先考虑
currentDay类的样式使用!important
关键字和您在类中定义的样式
.currentDay {
background-image:url('tick.jpg') !important;
background-repeat:repeat-x !important;
font-weight: bold !important;
color:#ad5 !important;
border: 1px solid #aaa !important;
}