title: jQuery .attr() not responding as expected
body: <p>I have a text field that holds a difference between days. I need to use it calculate something on my page. However, for some reason it is coming back as <code>undefined</code> when I do a <code>console.log()</code>. Any ideas?</p>
  
  <pre><code>&lt;script&gt;
          $(document).on('change', '#unitselector', function()
          {
              var unit = $('select option:selected').text();
              var rate = $(this).val();
              var tax = $('select option:selected').attr('label');
              var depart=$('#departdate').val();
              var arrival = $('#arrivaldate').val();
              var dataString = {unit:unit, depart:depart, arrival:arrival};
              console.log(dataString);
              //console.log($('.extracharges').serialize());
              $.ajax({
                  type: "POST",
                  url: "classes/unit_info.php",
                  data: dataString,
                  cache: false,
                  success: function(html)
                  {
                      $('.unitinfolist').html(html);
                  }
              });
  
              var days = $('#days').attr('name');
              var days2 = $('#days').attr('value');
              console.log('days: '+days);
              console.log('days: '+ days2 );
              $('.rentalcharges').find('#rent').val(rate*days);
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>and the PHP</p>
  
  <pre><code>$arrive = $_POST['arrival'];
  $leave = $_POST['depart'];
  
  $a = date_create($arrive);
  $d = date_create($leave);
  $diff = date_diff($d,$a);
  
  echo '&lt;input type="text" id="days" value="'.$diff-&gt;d.'" name="'.$diff-&gt;d.'" /&gt;';
  </code></pre>