title: How to use JavaScript variables in jQuery selectors?
body: <p>How do I use JavaScript variables as a parameter in a jQuery selector?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function(){    
    $("input").click(function(){
      var x = $(this).attr("name");
  
      $("input[id=x]").hide();    
    });    
  });
  &lt;/script&gt;
  
  &lt;input type="text" id="bx"/&gt;&lt;input type="button" name="bx"/&gt;
  &lt;input type="text" id="by"/&gt;&lt;input type="button" name="by"/&gt;
  </code></pre>
  
  <p>Basically what I want to do is to be able to hide the element which has an <code>id</code> that is equal to the name of the element that is being clicked.</p>