gog*_*net 1 javascript methods performance jquery chaining
每当检查顶级单选按钮时,我都试图清除表单元素上的一堆错误样式.我试图找到:
用于查找所有表单元素的链接方法,因此我没有进行如此多的调用..(不确定是否可能).
//在调用下面的函数之前定义的全局变量OR范围变量.
JS
var target = jQuery("#cachedElement");
function functionWithManyReferencesToTarget() {
target.find("input").each(function() {
$(this).removeClass("formError error-state");
});
target.find("label").each(function() {
$(this).removeClass("formError error-state");
});
target.find("select").each(function() {
$(this).removeClass("formError error-state");
});
}
Run Code Online (Sandbox Code Playgroud)
$target.find('input, label, select').removeClass('formError error-state');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2041 次 |
| 最近记录: |