javascript - 为什么我不能用 jQuery 删除 DOM 元素?
问题描述
这是我的一段代码,它应该只是从 HTML DOM 中删除一个元素,但由于某种原因它不会......
...
clearError(fields['server_error'][fieldUniqueId], 'server_error');
...
function clearError($field, type){
$("#" + getErrorLabelId($field, type)).remove();
}
function getErrorLabelId($field, type){
return ValidatorInstance.ErrorLabelIdPrefix + "-" + $field.data(ValidatorInstance.uniqueIdKey) + "-" + type;
}
所有函数都工作并返回它们期望的值。例如,如果我将线从更改为$("#" + getErrorLabelId($field, type)).remove();
完美$("#" + getErrorLabelId($field, type)).css('background.color', 'blue');
设置背景颜色。但它不会删除。这是为什么?
解决方案
推荐阅读
- ios - iOS app name displayed on the device is wrong?
- python - user choicen variable removed off list
- docker - Jenkins with SSL over Docker
- ios - 如何使用约束从下到上为 UIView 设置动画?
- python - How to insert large amount of numbers inside a number efficiently?
- javascript - When to use (a)synchronous calls?
- angular - how does the index page know which app tag to load
- windows - GIT 预提交钩子,它在修改/添加的文件中搜索非 UTF-8 编码(如果找到则拒绝提交)
- qt - QT Data Visualization in ROS Workspace Issue
- r - 使用`ddply`从两列中选择基于匹配对的列的最常见值