How do I iterate through children elements of a div using jQuery

0 votes
I have a div and it has several input elements in it... I'd like to iterate through each of those elements. Ideas?
Oct 5, 2020 in JQuery by kartik
• 37,520 points
5,553 views

1 answer to this question.

0 votes

Hello @kartik,

Use children() and each(), you can optionally pass a selector to children

$('#mydiv').children('input').each(function () {
    alert(this.value); // "this" is the current element in the loop
});

You could also just use the immediate child selector:

$('#mydiv > input').each(function () { /* ... */ });

Hope it helps!!
Thank you!!

answered Oct 5, 2020 by Niroj
• 82,840 points

Related Questions In JQuery

0 votes
0 answers

How to replace innerHTML of a div using jQuery?

How could I achieve the following: document.all.regTitle.innerHTML = ...READ MORE

May 31, 2022 in JQuery by Edureka
• 13,690 points
1,787 views
0 votes
1 answer

How do I select a sibling element using jQuery?

Use jQuery . siblings() to select the matching ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,690 points
489 views
0 votes
1 answer

How do I select a sibling element using jQuery?

jQuery siblings() Method The siblings() method returns all ...READ MORE

answered Jun 7, 2022 in JQuery by Edureka
• 13,690 points
2,441 views
0 votes
1 answer

How do I add options to a DropDownList using jQuery?

Without using any extra plugins, var myOptions = ...READ MORE

answered Jun 21, 2022 in JQuery by rajatha
• 7,680 points
522 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,062 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
3,013 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,939 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,856 views
0 votes
1 answer

How do I pre-populate a jQuery Datepicker textbox with today's date?

Hello @kartik, You must FIRST call datepicker() > then use ...READ MORE

answered May 29, 2020 in JQuery by Niroj
• 82,840 points
12,228 views
0 votes
1 answer

How can I determine the direction of a jQuery scroll event?

Hello @kartik, Check current scrollTop vs previous scrollTop var lastScrollTop = 0; $(window).scroll(function(event){ ...READ MORE

answered Nov 24, 2020 in JQuery by Niroj
• 82,840 points
878 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP