Skip to content
Advertisement

Using the jQuery each() function to loop through classname elements

I am trying to use jQuery to loop through a list of elements that have the same classname & extract their values.

I have this..

JavaScript

I was reading up on the each() function though got confused how to use it properly in this instance.

Advertisement

Answer

JavaScript

and if you wanted to get its index in the collection:

JavaScript

Reference: .each() and .val() functions.

Advertisement