Iterating over an array of selected jQuery objects?

How do you iterate over a group of selected jQuery objects so that you can execute jQuery functions on each object individually?

   
 <div class = "foobar"> abc </div>
 <div class = "foobar"> 123 </div>
 <div class = "foobar"> abc123 </div>

I can select a group:

var foobarObjects = jQuery('.foobar')

But how would you go through each jQuery object in foobarObject and manipulate each separately? I thought I could use it jQuery().each, but it only allows me to work with DOM objects, not jQuery objects. I also tried a for loop in conjunction with a function jQuery().eq(i), but this is like combining elements together.

+3
source share
2

$(this)

$('.foobar').each(function(){
  $(this).blah//refers to jquery object.
});
+22

jQuery().each() $(this) jQuery DOM.

+2

Source: https://habr.com/ru/post/1719904/


All Articles