Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a function after you find something in JQuery

I have a randomized set of input elements that appear when users select different options on a form. I want to find all the input boxes within a certain div by their classname and then call a function that sets those items to an array of objects. So far I have this:

$('.div-class-name').find('input.input-class-name:textbox')

I'm not sure where to go from here. I know what needs to go into the function once it is called but I don't know how to call it. How do I call a function after a find for all the returned elements?

Thank you in advance.

like image 761
seroth Avatar asked Sep 05 '25 12:09

seroth


1 Answers

$('.div-class-name').find('input.input-class-name').each(function(el) {
    //this will run for each matching input
    console.log($(this)); //$(this) is a jquery reference to the element in the list of matching ones
});
like image 185
mcgraphix Avatar answered Sep 08 '25 10:09

mcgraphix