Single cell table cleaner
by timmah
HTML
<h4 id="australian-climate-specific-stability-requirements"><a name="14-2-3-1"></a>Australian climate: specific stability requirements</h4>
<p>Major population centres in Australia experience a combination of high humidity and high temperature during the summer. These areas are classified as Zone IV regions.</p>
<ul>
<li>Ensure stability studies for medicines to be registered in Australia are performed under conditions representative of Zone IV regions.</li>
</ul>
<table>
<tbody>
<tr>
<td><h5 id="related-information-european-union-guidelines"><a name="related_info-guidance"></a>Related information and European Union guidelines</h5>
<ul>
<li><a href="http://apps.who.int/medicinedocs/en/m/abstract/Js19133en/" title="visit the WHO website">WHO Technical Report Series</a></li>
<li>Note for guidance on stability data package for registration in climatic zones III and IV (<a href="/node/4186#ich042102">CPMP/ICH/421/02</a>) (Adopted with annotations)</li>
</ul></td>
</tr>
</tbody>
</table>
JavaScript
// Replaces single cell tables containing only one cell with a clean div and class
$('table').each(function() {
var $this = $(this);
// Target tables with only one child cell
if ($this.find('td').length === 1) {
// Grab the HTML from the desired table cell
var $content = $this.find('td:last').html();
// Add the content in the desired HTML wrapper and place OUTSIDE the original table
// Add whatever classes you want for styling
$this.after('<div class="boxed noborder bg-greylt">' + $content + "</div>");
// Remove original table
$(this).remove();
}
});