title: val() is not a function when looping through elements
body: <p>I want to bind a value but I am getting the error below.</p>
  
  <blockquote>
    <p>val() is not a function.</p>
  </blockquote>
  
  <p>Please help me.</p>
  
  <pre><code>$(function() {
    $('.pic').each(function() {
      $(this).datepicker({
        dateFormat: "yy-mm-dd",
        onSelect: function() {
          var dateObject = $(this).datepicker('getDate');
          var date=$.datepicker.formatDate('yy-mm-dd', dateObject);
          $(this).attr('id').val(date);
        }
      });
  </code></pre>