title: javascript check if string contain only html
body: <p>this is my string</p>
  
  <pre><code>&lt;img class="img" src="a.png"&gt;&lt;img class="img" src="a.png"&gt;&lt;img class="img" src="a.png"&gt; 
  </code></pre>
  
  <p>i want to check if string contain only html tags </p>
  
  <pre><code>dwd&lt;img class="img" src="a.png"&gt;dwd&lt;img class="img" src="a.png"&gt;&lt;img class="img" src="a.png"&gt; dwd
  </code></pre>
  
  <p>if contain any string like example above i want to return false</p>
  
  <p>i have some code here for check about thats</p>
  
  <pre><code>function isHTML(str) {
    var a = document.createElement('div');
    a.innerHTML = str;
  
    for (var c = a.childNodes, i = c.length; i--; ) {
      if (c[i].nodeType == 1) return true; 
    }
  
    return false;
  }
  
  
  isHTML('&lt;a&gt;this is a string&lt;/a&gt;') // true
  isHTML('this is a string')        // false
  isHTML('this is a &lt;b&gt;string&lt;/b&gt;') // true
  </code></pre>
  
  <p>as we can see in third example its return true and there is some string with html tags so how can i edit that's and make it return true if only there are html tags none text</p>
  
  <p>another method here but same above</p>
  
  <pre><code>var isHTML = RegExp.prototype.test.bind(/(&lt;([^&gt;]+)&gt;)/i);
  
  isHTML('Testing');               // false
  isHTML('&lt;p&gt;Testing&lt;/p&gt;');        // true
  isHTML('&lt;img src="hello.jpg"&gt;'); // true
  isHTML('My &lt;p&gt;Testing&lt;/p&gt; string');   // true (caution!!!)
  isHTML('&lt;&gt;');                    // false
  </code></pre>
  
  <p>its good method but <code>isHTML('My &lt;p&gt;Testing&lt;/p&gt; string');   // true (caution!!!)</code></p>
  
  <p>here i want to return false because there is some string with the html tags</p>