我目前在一个存储在一个函数中的数组中存储了几个jQuery片段。一旦我从我的代码库调用函数,就会执行每个jQuery代码片段。因此,阻止我在阵列中工作。每次调用函数时都不要执行存储在数组中的jQuery
下面的代码是一个例子:
var remove = [
jQuery("#mesh option:selected").removeAttr("selected"),
jQuery("#pipetype option:selected").removeAttr("selected"),
jQuery("#caboption option:selected").removeAttr("selected"),
jQuery("#bedsize option:selected").removeAttr("selected"),
jQuery("#model option:selected").removeAttr("selected"),
jQuery("#year option:selected").removeAttr("selected"),
];
for (var i = 0; i <= amount; i++) {
remove[i];
}
我怎么能保证,当deselect()
被调用时,只有少数的数组元素得到执行,而不是所有的人?
谢谢!