title: How to get current html value of a class with click on another class element
body: <p>I fetching data from database, In which i want to get current class html value with on click on another nearest class, And show it on another input tag.</p>
  
  <p><strong>script</strong></p>
  
  <pre><code>while($row = $query-&gt;fetch(PDO:: FETCH_ASSOC)) {
      $player= $row-&gt;['player'];
      $runs = $row-&gt;['runs'];
      $balss= $row-&gt;['balls'];
  
      $Name = "&lt;strong class='player'&gt; $player &lt;/strong&gt;"; 
      $score = "&lt;i class='runs'&gt; $runs &lt;/i&gt;";
      $balls= "&lt;i class='balls'&gt; $balls&lt;/i&gt;";
  
      }
  
  &lt;div class="popup"&gt;
  &lt;input type="text" id="player" &gt;
  &lt;input type="text" id="runs" &gt;
  &lt;input type="text" id="balls" &gt;
  &lt;/div&gt;
  
  
  $(document).on('click', '.player', function(){
      $(".popup").toggle();
      var player = document.getElementsByClassName('player');
      for (var i = 0; i &lt; player.length; i++)
      $("#player").val(player[i].html);
  
      var score = document.getElementsByClassName('runs');
      for (var i = 0; i &lt; score.length; i++)
      $("#runs").val(score[i].html);
  });
  </code></pre>