-3

What is below jQuery code performing ?

    inputMapVar.each(function(index){              
      $(this).prev().removeClass(MISSING); 
    });
1

5 Answers 5

5

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.

Sign up to request clarification or add additional context in comments.

Comments

3

Looping through the inputMapVar collection, finding the previous element in the DOM, then removing the CSS class stored in the MISSING variable

Comments

1

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.

Comments

0

Nothing.... if "MISSING" were in quotes, it would remove the CSS Class ".missing" from each of the previous elements that match whatever inputMapVar is.

1 Comment

MISSING may be defined elsewhere in the code, try looking for 'var MISSING'.
0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.