title: How do I empty an input value with jQuery?
body: <p>I’m trying to make a modal dialog with images where you can select multiple images. I need to get values from an input and then to empty it, but I cannot empty the input. I tried <code>.val('')</code> and <code>.val(null)</code>, but neither worked for me.</p>
  
  <p>Here is the full code:</p>
  
  <pre><code>$("#hdselect").click(function(){
          $(".modal").html("");
  
          $.post('mediaservice.php',{hd:'ok',images:$("#hdimages").val()},function(data){
              $(".modal").append(data);
          });
          $(".modal").dialog({
              'modal':true,
              'title':"Click the image to select",
              'width':960,
              'height':600,
              'resizable':false,
              'show': {effect: 'drop', direction: "up"},
              'buttons': {"Ok": function() {  
                      var hd=Array();
                      var hdval=$("#hdimages").val();
                      $("#hdimages").attr('value',' ');
                      $("input[name='hd[]']:checked").each(function(){
                          hd.push($(this).val());
                      });
                      if(hdval!=''){
                          hdval=hdval+","+hd;
                      }else{
                          hdval=hd;
                      }                        
                      $("#hdimages").val(hdval);
                      var images=$("#hdimages").val();
                      $.post('mediaservice.php',{getHd:images},function(data){
                          $("#imgthumbBase").append(data);
                      });
                      $(this).dialog("close");
                  }
              }
          });
      });
  </code></pre>
  
  <p>The idea is that the user clicks a button and a  modal dialog opens with multiple images and checkboxes. At this point I need to get the values from an input, and then clear it.</p>