title: how can I apply function if element has that attribute with value
body: <p>I want that if svg has attribute <code>aria-label=&quot;Like&quot;</code> then execute a function and if it doesn't have attribute <code>aria-label=&quot;Like&quot;</code> then other function execute.
  Can any one tell me that how can I select attribute with attribute value to execute function.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>        function fn() {
              var likebtn = document.querySelector('.fr66n .wpO6b');
              var unliked = document.querySelector('.fr66n .wpO6b svg[aria-label=Like]');
              var x = document.querySelector('#demo');
  
              if (unliked === true) {
                  x.innerHTML = "has"
              } else {
                  x.innerHTML = "not"
              }
  
          }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    &lt;span class="fr66n"&gt;
          &lt;button class="wpO6b  " type="button"&gt;
              &lt;div class="QBdPU "&gt;
                  &lt;span class="intro"&gt;
                      &lt;svg aria-label="like" class="_8-yf5 " fill="#262626" height="24" role="img" viewBox="0 0 48 48" width="24"&gt;
                          &lt;path d="M34.6 6.1c5.7 0 10.4 5.2 10.4 11.5 0 6.8-5.9 11-11.5 16S25 41.3 24 41.9c-1.1-.7-4.7-4-9.5-8.3-5.7-5-11.5-9.2-11.5-16C3 11.3 7.7 6.1 13.4 6.1c4.2 0 6.5 2 8.1 4.3 1.9 2.6 2.2 3.9 2.5 3.9.3 0 .6-1.3 2.5-3.9 1.6-2.3 3.9-4.3 8.1-4.3m0-3c-4.5 0-7.9 1.8-10.6 5.6-2.7-3.7-6.1-5.5-10.6-5.5C6 3.1 0 9.6 0 17.6c0 7.3 5.4 12 10.6 16.5.6.5 1.3 1.1 1.9 1.7l2.3 2c4.4 3.9 6.6 5.9 7.6 6.5.5.3 1.1.5 1.6.5.6 0 1.1-.2 1.6-.5 1-.6 2.8-2.2 7.8-6.8l2-1.8c.7-.6 1.3-1.2 2-1.7C42.7 29.6 48 25 48 17.6c0-8-6-14.5-13.4-14.5z"&gt;&lt;/path&gt;
                      &lt;/svg&gt;
                  &lt;/span&gt;
      &lt;/div&gt;
      &lt;/button&gt;
      &lt;/span&gt;
      &lt;button onclick="fn()"&gt;call fn&lt;/button&gt;
      &lt;p id="demo"&gt;&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>