Interviewer And Interviewee Guide

JQuery Developer Interview Question:

What is the use of jquery .each() function?

Submitted by: Administrator
Basically, the jQuery .each() function is used to loop through each element of the target jQuery object. Very useful for multi element DOM manipulation, looping arrays and object properties.

Example:
In this example alert box will open 3 times because dom contain 3 <li> tags
<script>
$(document).ready(function(){
$("button").click(function(){
$("li").each(function(){
alert($(this).text())
});
});
});
</script>

<ul>
<li>Coffee</li>
<li>Milk</li>
<li>Soda</li>
</ul>
Submitted by:

Read Online JQuery Developer Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.