# JQuery Each Method

In 
web
Published 2022-12-03

This tutorial explains to you how to use each method in JQuery.

Here is a cod to run for seeing how the "each" method works in JQuery:

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("li").each(function(){
            alert("Name= "+$(this).text())
        });
    });
});
</script>
</head>
<body>
 
<button>Press the button to pass through all the values of the list</button>
 
<ul>
  <li>John</li>
  <li>Andrew</li>
  <li>Paul</li>
</ul>
 
</body>
</html>

Here is the result of the code above:

Click on the button and you will see:

This is the "each" method behaviour ! 😊