Showing posts with label Jquery Each function. Show all posts
Showing posts with label Jquery Each function. Show all posts

29 December 2021

Iterate Array of Objects using Jquery each function


<!DOCTYPE html>
<html>
  <head>
    <script src="js/jquery-3.6.0.js"></script>
    <script>
      $(document).ready(function () {
        var obj= [
          { FName: "Adi" , LName:"JC"},
          { FName: "Pavan" , LName:"JC"},
          { FName: "Madhan" , LName:"JC"},
          { FName: "Yagnesh" , LName:"JC"}
        ]
   $.each(obj, function (index, value) {
          console.log(value.FName+" "+value.LName);
   });
      });
    </script>
  </head>
  <body></body>
</html>

 

Github Link: https://github.com/adi501/JQuery-Examples


Iterate array elements using Jquery each function

 

<!DOCTYPE html>
<html>
  <head>
    <script src="js/jquery-3.6.0.js"></script>
    <script>
      $(document).ready(function () {
        var arrNumber = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
        $.each(arrNumber, function (index, value) {
          console.log(index + " : " + value);
        });
      });
    </script>
  </head>
  <body></body>
</html>

Github Link: https://github.com/adi501/JQuery-Examples