title: Best way to find anchor tag not containing href attribute?
body: <p>I have a html string.. Some of the anchor tags in it doesnt have href attribute (without href attribute and without any value). I am trying to remove those tags from the HTML string</p>
  
  <p>Example:</p>
  
  <pre><code>&lt;div class="parsys ReferenceA"&gt;&lt;div class="parbase section reference"&gt;&lt;div style="display:inline;" class="cq-dd-paragraph"&gt;&lt;div class="warrantyinfo warrantyinfo_3"&gt; 
   &lt;link rel="stylesheet" href="http://test.com/media/test.css" type="text/css"&gt; 
           &lt;div class="box note warranty-info hidebox"&gt; 
                   &lt;p&gt;&lt;a name="test" data-cqpath="234492921271682679940756642751399440576;2014296"&gt;&lt;/a&gt;&lt;b&gt;some text&lt;/p&gt; 
           &lt;/div&gt; 
          &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;div class="parbase section reference"&gt;&lt;div style="display:inline;" class="cq-dd-paragraph"&gt;&lt;div class="warrantyinfo"&gt; 
   &lt;link rel="stylesheet" href="http://test.com/media/test.css" type="text/css"&gt; 
           &lt;div class="box note warranty-info hidebox"&gt; 
                   &lt;p&gt;&lt;a name="test" data-cqpath="84618115959711848855398939109764576374;2014212"&gt;&lt;/a&gt;some text&lt;/p&gt; 
           &lt;/div&gt; 
          &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;div class="parbase section reference"&gt;&lt;div style="display:inline;" class="cq-dd-paragraph"&gt;&lt;div class="warrantyinfo_0 warrantyinfo"&gt; 
   &lt;link rel="stylesheet" href="http://test.com/media/test.css" type="text/css"&gt; 
           &lt;div class="box note warranty-info hidebox"&gt; 
                   &lt;p&gt;&lt;b&gt;Bsome text&lt;br&gt; 
  &lt;br&gt; 
  &lt;b&gt;some text/p&gt; 
           &lt;/div&gt; 
          &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;div class="parbase section reference"&gt;&lt;div style="display:inline;" class="cq-dd-paragraph"&gt;&lt;div class="warrantyinfo"&gt; 
   &lt;link rel="stylesheet" href="http://test.com/media/test.css" type="text/css"&gt; 
           &lt;div class="box note warranty-info hidebox"&gt; 
                   &lt;p&gt;some text&lt;br&gt; 
  &lt;/p&gt; 
           &lt;/div&gt; 
          &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;div class="parbase section reference"&gt;&lt;div style="display:inline;" class="cq-dd-paragraph"&gt;&lt;div class="warrantyinfo"&gt; 
   &lt;link rel="stylesheet" href="http://test.com/test,css" type="text/css"&gt; 
           &lt;div class="box note warranty-info hidebox"&gt; 
                   &lt;p&gt;some text&lt;/p&gt; 
  &lt;p&gt;&lt;/p&gt; 
           &lt;/div&gt; 
          &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;/div&gt;
  </code></pre>
  
  <p>I tried the below code but didn't work</p>
  
  <p>data is a html string returned on ajax request.</p>
  
  <pre><code>var newHtml = $('&lt;div&gt;' + data + '&lt;/div&gt;');
  newHtml.find("a:not([href])").replaceWith(function() { return this.childNodes; });
  var content = newHtml.html();
  </code></pre>
  
  <p>Any inputs is appreciated..</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Added sample html.</p>
  
  <p>For some reason empty tags are not getting replaced at all.</p>
  
  <p><a href="http://jsfiddle.net/8WpDn/51/" rel="nofollow">http://jsfiddle.net/8WpDn/51/</a></p>
  
  <p>If I inspect the output html I can still see the below emppty  tag</p>
  
  <pre><code>&lt;p&gt;&lt;a name="test" data-cqpath="84618115959711848855398939109764576374;2014212"&gt;&lt;/a&gt;some text&lt;/p&gt;
  </code></pre>