Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Brett - are you aware that <a href="http://www.quirksmode.org/dom/w3c_core.html#gettingelements"><code>getElementyByClassName</code></a> support from IE 5.5 to 8 is <a href="http://www.quirksmode.org/dom/w3c_core.html#gettingelements"><em>not there</em> according to quirksmode</a>?. You would be better off following this pattern if you care about cross-browser compatibility:</p> <ul> <li>Get container element by ID.</li> <li>Get needed child elements by tag name.</li> <li>Iterate over children, test for matching className property.</li> <li><code>elements[i].parentNode.removeChild(elements[i])</code> like the other guys said.</li> </ul> <p>Quick example:</p> <pre><code>var cells = document.getElementById("myTable").getElementsByTagName("td"); var len = cells.length; for(var i = 0; i &lt; len; i++) { if(cells[i].className.toLowerCase() == "column") { cells[i].parentNode.removeChild(cells[i]); } } </code></pre> <p><a href="http://jsfiddle.net/AzyBf/"><strong>Here's a quick demo.</strong></a></p> <p>EDIT: Here is the fixed version, specific to your markup:</p> <pre><code>var col_wrapper = document.getElementById("columns").getElementsByTagName("div"); var elementsToRemove = []; for (var i = 0; i &lt; col_wrapper.length; i++) { if (col_wrapper[i].className.toLowerCase() == "column") { elementsToRemove.push(col_wrapper[i]); } } for(var i = 0; i &lt; elementsToRemove.length; i++) { elementsToRemove[i].parentNode.removeChild(elementsToRemove[i]); } </code></pre> <p>The problem was my fault; when you remove an element from the resulting array of elements, the length changes, so one element gets skipped at each iteration. The solution is to store a reference to each element in a temporary array, then subsequently loop over those, removing each one from the DOM.</p> <p><a href="http://jsfiddle.net/k6z6p/1/"><strong>Try it here.</strong></a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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