Reputation: 53896
What is below jQuery code performing ?
inputMapVar.each(function(index){
$(this).prev().removeClass(MISSING);
});
Upvotes: -3
Views: 115
Reputation: 935
Looping through the inputMapVar collection, finding the previous element in the DOM, then removing the CSS class stored in the MISSING variable
Upvotes: 3
Reputation: 34820
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.
Upvotes: 1
Reputation: 22029
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.
Upvotes: 0
Reputation: 43617
Nothing.... if "MISSING" were in quotes, it would remove the CSS Class ".missing" from each of the previous elements that match whatever inputMapVar is.
Upvotes: 0
Reputation: 13362
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.
Upvotes: 5