title: Using a variable for value inside jQuery attribute-equals-value selector
body: <p>I have a <code>div</code> with an attribute of "foldername" which can something like "shoes, "dresses," etc . The div looks like this:</p>
  
  <pre><code>&lt;div id='folder_template' class="openclosed_folder_icon subfolder" foldername="shoes"&gt;
      &lt;img class="folder_icon" src="images/folder_closed.png"  /&gt;
      &lt;div class="folder_label"&gt;name&lt;/div&gt; 
  &lt;/div&gt; 
  </code></pre>
  
  <p>I want to search for the div that has a particular value for foldername and change the image in it from "folder_closed.png" to "folder_open.png," so the graphic looks like an open folder instead of a closed folder. So I have the code:</p>
  
  <pre><code>$("div[foldername=g.currentGallery]").attr('src','images/folder_open.png'); 
  </code></pre>
  
  <p>where g.currentGallery is a variable holding the gallery name, e.g., "shoes," that I want to change.
  But this line gives me the error:</p>
  
  <blockquote>
    <p>Syntax error, unrecognized expression:
    div[foldername=g.currentGallery]</p>
  </blockquote>
  
  <p>But it will take:</p>
  
  <pre><code>$("div[foldername='shoes']").attr('src','images/folder_open.png');
  </code></pre>
  
  <p>Why can't I use a variable here?</p>