Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery - Remove self-closing tags in HTML
    text
    copied!<p>I am working on a navigation for a site that is composed of several jQuery accordions containing lists of links, like this:</p> <pre><code>&lt;ul class="menu"&gt; &lt;li&gt; &lt;h3&gt;Header 1&lt;/h3&gt; &lt;ul&gt; &lt;li class="menuItem"&gt;Link 1&lt;/li&gt; &lt;li class="menuItem"&gt;Link 2&lt;/li&gt; &lt;li class="menuItem"&gt;Link 3&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;h3&gt;Header 2&lt;/h3&gt; &lt;ul&gt; &lt;li class="menuItem"&gt;Link 4&lt;/li&gt; &lt;li class="menuItem"&gt;Link 5&lt;/li&gt; &lt;li class="menuItem"&gt;Link 6&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>The CMS that the site is built on, for some reason, sets any empty lists as self-closing <code>&lt;li&gt;</code> tags, like this:</p> <pre><code>&lt;ul class="menu"&gt; &lt;li&gt; &lt;h3&gt;Header 1&lt;/h3&gt; &lt;ul&gt; &lt;li class="menuItem"&gt;Link 1&lt;/li&gt; &lt;li class="menuItem"&gt;Link 2&lt;/li&gt; &lt;li class="menuItem"&gt;Link 3&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li /&gt; &lt;/ul&gt; </code></pre> <p>I am wondering if there is a way to find and remove all <code>&lt;li /&gt;</code> tags from the HTML using jQuery. Thanks!</p> <p><strong>EDIT:</strong> I forgot to mention, this only shows up in IE7. In IE8/9, the browser has <code>&lt;li&gt;&lt;/li&gt;</code> in the HTML, but it doesn't render these tags as anything. The <code>&lt;li /&gt;</code> tag affects the layout in IE7 (it looks like it's being rendered as a block element, so it's pushing the content below it down).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload