Closed. This question is off-topic。它当前不接受答案。
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
5年前关闭。
我正在尝试使用jQuery 1.10.2更改DOM元素的类属性(特别是对于标签标签)。
这是我的代码:
但我得到一个错误:
TypeError:value.atrr不是函数
您能告诉我我在做什么错以及如何正确做。
非常感谢任何帮助。
先感谢您,
错义
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
5年前关闭。
我正在尝试使用jQuery 1.10.2更改DOM元素的类属性(特别是对于标签标签)。
这是我的代码:
var MyNameSpace = MyNameSpace || {};
MyNameSpace.enableDisableLabels = (function() {
var m_labelIds = {
"bookId": "book",
"customerId": "customer"
};
var mf_getjQueryDOMObjectReperesentation = function(arrayObjIds) {
var result = {};
$.each(arrayObjIds, function(id, value) {
result[id] = $("#" + value);
});
return result;
};
var mf_unBoldLabels = function(arrayjQueryObjLabels) {
$.each(arrayjQueryObjLabels, function(id, value) {
value.atrr("class", "outputLabelOpt"); // PROBLEM: TypeError: value.atrr is not a function
});
};
var arrayjQueryObjLabels = mf_getjQueryDOMObjectReperesentation(m_labelIds);
mf_unBoldLabels(arrayjQueryObjLabels);
}());
.outputLabelOpt {
color: #0B63CA;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<body>
<label id="book" style="font-weight:bold">book</label>
<label id="customer" style="font-weight:bold">customer</label>
</body>
但我得到一个错误:
TypeError:value.atrr不是函数
您能告诉我我在做什么错以及如何正确做。
非常感谢任何帮助。
先感谢您,
错义
最佳答案
只是一个错字:不是atrr
,而是attr
;-)
关于javascript - 如何使用jQuery更改多个DOM元素的CSS类? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26076824/
10-11 14:12