title: How to get the div name in javaScript?
body: <p>I want to get the div name at <code>alert(name)</code>, but it gives as "undifined". The values come from a database. All other alerts are working fine.</p>
  
  <p>Here is my HTML code.</p>
  
  <pre><code>&lt;input class="rating form-control input-star-rate" id="&lt;?php echo $rateid; ?&gt;" name="&lt;?php echo $arate_num; ?&gt;" value="&lt;?php echo $ratea; ?&gt;" data-min="0" data-max="5" data-step="0.3" data-size="xs" style="display: none; text-align: center;" onchange="changeRate(this)"/&gt;
  </code></pre>
  
  <p>Here is my javaScript code.</p>
  
  <pre><code>function changeRate(id) {
      var ratingValue = id.value;
      var ratingValue2 = parseFloat(ratingValue);
      alert(ratingValue2);
  
      var ratingValuePrevious = id.getAttribute('value');
      var ratingValuePrevious2 = parseFloat(ratingValuePrevious);
      alert(ratingValuePrevious2);
  
      var id = id.id;
      alert(id);
  
      var name = id.name;
      alert(name);
  }
  </code></pre>