title: How can I use document.querySelector to select this class name with a space in it?
body: <pre><code>&lt;a href="javascript:void(0)" class="PrmryBtnMed"
   id = "VERYLONGTEXT"
  
  onclick="$(this).parents('form').submit(); return false;"&gt;&lt;span&gt;Dispatch to this address&lt;/span&gt;&lt;/a&gt;
  </code></pre>
  
  <p>I have been using </p>
  
  <pre><code>var inPage = document.documentElement.innerHTML.indexOf('text to search') &gt; 0,
      el = document.querySelector(".PrmryBtnMed");
  
  if (inPage &amp;&amp; el) el.click();
  </code></pre>
  
  <p>But now, the class name has changed: there’s a space and some new text in the class name:</p>
  
  <pre><code>&lt;a href="javascript:void(0)" class="PrmryBtnMed ApricotWheat"
   id = "VERYLONGTEXT"
  onclick="ApricotWheat(this); return false;"&gt;&lt;span&gt;Dispatch to this address&lt;/span&gt;&lt;/a&gt;
  </code></pre>
  
  <p>How can I change <code>el = document.querySelector(".PrmryBtnMed");</code>
  to find the right class? </p>
  
  <p>I tried using <code>el = document.querySelector(".PrmryBtnMed.ApricotWheat");</code> but that didn’t work. </p>
  
  <p>Next, I tried to add a space (and escape using a backslash): <code>el = document.querySelector(".PrmryBtnMed\ ApricotWheat");</code> but that didn’t work either. </p>
  
  <p>So, I wondered if I could use <code>%20</code> for the space.. but no luck. </p>
  
  <p>I’d be very grateful for some help! What am I doing wrong? </p>