title: Traversing the dom for nested objects
body: <p>I have nested inputs in my html which I am trying to get the value of. I've tried many methods with no luck.
  I want to get the value of all the inputs into different variables in my javascript file.</p>
  
  <h2>This is my HTML :</h2>
  
  <pre><code>&lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;title&gt;HotGym&lt;/title&gt;
      &lt;meta name="ROBOTS" content="NOINDEX, NOFOLLOW"&gt;
      &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;
      &lt;meta http-equiv="content-language" content="he"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"&gt;
      &lt;meta http-equiv="CACHE-CONTROL" content="NO-CACHE"&gt;
      &lt;link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"&gt;
      &lt;link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/master.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/addTrainee.css"&gt;
      &lt;link rel="shortcut icon" href="imgs/icon.png" type="image/x-icon"&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div class="addNav"&gt;&lt;/div&gt;
      &lt;div class="pages"&gt;
          &lt;div class="page"&gt;
              &lt;h2 class="headline"&gt;Adding Trainee&lt;/h2&gt;
              &lt;div class="add_trainee"&gt;
                  &lt;form&gt;
                      &lt;div class="inp"&gt;
                          &lt;p&gt;Full name&lt;/p&gt;
                          &lt;input spaceholder="please enter fullname" type="text" class="fullName"&gt;
                      &lt;/div&gt;
                      &lt;div class="inp"&gt;
                          &lt;p&gt;Gender&lt;/p&gt;
                          &lt;input spaceholder="please  enter" type="text" class="gender"&gt;
                      &lt;/div&gt;
                      &lt;div class="inp"&gt;
                          &lt;p&gt;Age&lt;/p&gt;
                          &lt;input require spaceholder="please enter fullname" type="number" class="age"&gt;
                      &lt;/div&gt;
                      &lt;div class="inp"&gt;
                          &lt;p&gt;Phone number&lt;/p&gt;
                          &lt;input spaceholder="please enter fullname" type="text" class="phoneNumber"&gt;
                      &lt;/div&gt;
                      &lt;div class="inp"&gt;
                          &lt;p&gt;Adress&lt;/p&gt;
                          &lt;input spaceholder="please enter fullname" type="text" class="adress"&gt;
                      &lt;/div&gt;
                      &lt;div class="inp"&gt;
                          &lt;p&gt;Medical assurance Date&lt;/p&gt;
                          &lt;input spaceholder="please enter fullname" type="date" class="dateMedicalAssuranceEnd"&gt;
                      &lt;/div&gt;
                      &lt;div class="inp"&gt;
                          &lt;p&gt;Date start memebership&lt;/p&gt;
                          &lt;input spaceholder="please enter fullname" type="date" class="dateMembershipStart"&gt;
                      &lt;/div&gt;
                      &lt;div class="inp"&gt;
                          &lt;p&gt;Date end memebership&lt;/p&gt;
                          &lt;input spaceholder="please enter fullname" type="date" class="dateMembershipEnd"&gt;
                      &lt;/div&gt;
                      &lt;div class="inp"&gt;
                          &lt;input class="addTrainee" type="submit" name="submit" value="save"&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;script src="jquery/dist/jquery.js"&gt;&lt;/script&gt;
              &lt;script src="js/add-trainee-main.js" type="module"&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p>my jquery looks like this :
  the 'addBtn' is correct , and iv tryed many methods from here :</p>
  
  <h2><a href="https://api.jquery.com/category/traversing/" rel="nofollow noreferrer">https://api.jquery.com/category/traversing/</a></h2>
  
  <pre><code> handleAddTrainee() {
          // console.log(this);
          let addBtn = $('.addTrainee');
          // console.log(addBtn)
          debugger
          // $('.addTrainee').on('click', () =&gt; {
          // let $traineeForm = $(this).closest('.trainee-from') // need to know the way you orginized the html.
  
          // cetch trainee data 
  
          //----
          let fullName = addBtn.closest('.add_trainee').find('.inp').find('input.fullName').val();
          let gender = $(this).closest('.gender').val();
          let age = $(this).closest('.age').val();
          let phoneNumber = $(this).closest('.phoneNumber').val();
          let adress = $(this).closest('.adress').val();
          let dateMedicalAssuranceEnd = $(this).closest('.dateMedicalAssuranceEnd').val();
          let dateMembershipStart = $(this).closest('.dateMembershipStart').val();
          let dateMembershipEnd = $(this).closest('.dateMembershipEnd').val();
          //-----
          let traineeForm = {
              fullName: fullName,
              gender: gender,
              age: age,
              phoneNumber: phoneNumber,
              adress: adress,
              dateMedicalAssuranceEnd: dateMedicalAssuranceEnd,
              dateMembershipStart: dateMembershipStart,
          }
          this.gymRepo.addTrainee(traineeForm).then(() =&gt; {
                  alert("new trainee as been saved");
              })
              // })
      }
  </code></pre>