【发布时间】:2016-03-14 16:29:27
【问题描述】:
我的 JQuery 代码将类添加到 html,但我没有看到任何视觉变化,有人知道为什么吗?我正在使用 DevExpress、Webforms。
.BoldRed {
font-weight:bold;
color:red;
}
function onTextBoxInit(s, e) {
if (s.GetText().indexOf('1') > -1)
$(s.GetInputElement()).addClass("BoldRed");
else
$(s.GetInputElement()).removeClass("BoldRed");
}
实际输出:
<input class="dxeEditArea_DevEx dxeEditAreaSys BoldRed" name="ctl00$ctl00$ASPxSplitter1$Content$ContentSplitter$MainContent$ASPxCallbackPanel1$ASPxFormLayout3$ASPxFormLayout3_E1" value="106971" id="ASPxFormLayout3_E1_I" onchange="aspxEValueChanged('ASPxFormLayout3_E1')" onblur="aspxELostFocus('ASPxFormLayout3_E1')" onfocus="aspxEGotFocus('ASPxFormLayout3_E1')" type="text" readonly="readonly" style="background-color: rgb(192, 224, 206);font-weight: bold; color:red;">
【问题讨论】:
-
style属性会覆盖 css 文件中的任何内容 - 该按钮已经指定了font-weight和color,因此 CSS 将无法更改它,除非您走糟糕的路线(此处未注明,因为我很确定您的问题是所有按钮都在style中,而不仅仅是您要设置样式的类)
标签: javascript jquery css webforms devexpress