What is below jQuery code performing ?
开发者_StackOverflow中文版 inputMapVar.each(function(index){
$(this).prev().removeClass(MISSING);
});
This code is looping through (.each()
) the elements of inputMapVar
and getting the element before each one (.prev()
) and then removing the class from that element (.removeClass()
) with the class name to remove being the value of the variable MISSING
.
Edit Just for the sake of clarity, $(this)
gets the current element in the loop in this case.
Looping through the inputMapVar collection, finding the previous element in the DOM, then removing the CSS class stored in the MISSING variable
That code would iterate over all the CSS classes applied to the DOM object represented by this
and remove the ones called "MISSING". I believe there's a syntax problem, however- the MISSING should be surrounded by quotes, as I believe removeClass
takes a string subtype.
Nothing.... if "MISSING" were in quotes, it would remove the CSS Class ".missing" from each of the previous elements that match whatever inputMapVar is.
For each element in the array inputMapVar
, run the function with parameter index
.
The callback function ran on each element will get the element preceding the element within the array, and remove the class.
MISSING
must (or should) be a variable containing the class name.
精彩评论