Rebecca O'Sullivan Rebecca O'Sullivan - 1 year ago 60
Javascript Question

How to I find all elements on a page that have a null id and remove them?

I want to check for ANY element on the page where the id has no value, and then remove them using jQuery's


This is how the id's look when they have no value passed from the CMS:

<iframe id class="iframeCol"...></iframe>
<div id class="sectional">..</div>

How do I target any and all elements where the id is as above?

Answer Source

You can use the attribute selector to achieve this:

<script src=""></script>

<iframe id class="iframeCol">Remove this</iframe>
<div id class="sectional">And remove this</div>

<div>Keep this</div>
<div id="foo">And this</div>