title: How to check if a div has an svg in it using JavaScript?
body: <p>I have a div like the following with a question mark in it...</p>
  
  <pre><code>&lt;div id="mydiv"&gt;?&lt;/div&gt;
  </code></pre>
  
  <p>In my code, when someone tries to submit a form, I do a check to see if that field has a question mark in it, like this:</p>
  
  <pre><code>const fieldText = $('#mydiv').text();
  return fieldText.indexOf('?') !== -1;
  </code></pre>
  
  <p>That works fine, but now, instead of a question mark in that div, I have an SVG of a question mark (rather than just a text question mark), like this.</p>
  
  <pre><code>&lt;div id="mydiv"&gt;
    &lt;svg version='1.1' id='Layer_1' class='q-mark-svg' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 50 50' style='enable-background:new 0 0 50 50;' xml:space='preserve'&gt;
      &lt;style type='text/css'&gt;
        .q-mark{fill:#777777;}
      &lt;/style&gt;
      &lt;g&gt;
        &lt;g&gt;
          &lt;path class='q-mark' d='M18.3,17.2c0,0.4-0.1,0.7-0.2,1c-0.1,0.3-0.3,0.6-0.5,0.8c-0.2,0.2-0.5,0.4-0.8,0.5c-0.3,0.1-0.6,0.2-1,0.2 c-0.7,0-1.3-0.2-1.8-0.7c-0.5-0.5-0.7-1.1-0.7-1.8c0-1.6,0.3-3.2,0.9-4.6c0.6-1.4,1.5-2.7,2.6-3.8s2.3-1.9,3.8-2.5 c1.4-0.6,3-0.9,4.6-0.9s3.1,0.3,4.6,1c1.4,0.6,2.7,1.5,3.8,2.6s1.9,2.3,2.6,3.8c0.6,1.4,0.9,2.9,0.9,4.5c0,3.2-1.2,6-3.5,8.4 l-3.8,3.5c-1.3,1.3-2,2.7-2,4.3c0,0.7-0.2,1.3-0.7,1.8c-0.5,0.5-1.1,0.7-1.8,0.7s-1.3-0.2-1.8-0.7c-0.5-0.5-0.7-1.1-0.7-1.8 c0-2.9,1.2-5.6,3.5-7.9l3.8-3.6c1.3-1.4,2-2.9,2-4.8c0-0.9-0.2-1.8-0.5-2.6c-0.4-0.8-0.8-1.5-1.5-2.1c-0.6-0.6-1.3-1.1-2.1-1.5 c-0.8-0.4-1.7-0.5-2.6-0.5c-0.9,0-1.8,0.2-2.6,0.5c-0.8,0.4-1.5,0.8-2.1,1.4c-0.6,0.6-1.1,1.3-1.4,2.1 C18.5,15.3,18.3,16.2,18.3,17.2z M28.5,40.9c0,1-0.3,1.8-1,2.5c-0.7,0.7-1.5,1-2.5,1c-1,0-1.8-0.3-2.5-1c-0.7-0.7-1-1.5-1-2.5 c0-1,0.3-1.8,1-2.5c0.7-0.7,1.5-1,2.5-1c1,0,1.8,0.3,2.5,1C28.2,39.1,28.5,40,28.5,40.9z'/&gt;
        &lt;/g&gt;
      &lt;/g&gt;
    &lt;/svg&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I still want to run a check on that div, but now I have to check to see if it has an SVG in it, rather than just "?".  How can I use JS to check if a div has an svg element in it?</p>
  
  <p>FYI, I tried the following since I thought it would still look for the text, but to no avail...</p>
  
  <pre><code>const fieldText = $('#mydiv').text();
  return fieldText.indexOf('svg') !== -1;
  </code></pre>