Jump to content

Create div within elements based on class


Daniel St. Jules

Recommended Posts

Hey everyone, I was hoping to receive a little help in figuring out how to accomplish this fix of mine. For a recent design I need to create a little workaround for IE. Basically I need to find all td's with class "a, and create a div within those td's, surrounding its contents with class "b". So, if I had

<table>
<tr>
	<td class="a">
		Content here
		<table>
			<tr>
				<td class="a">
					More Content here
				</td>
			</tr>
		</table>
	</td>
</tr>
</table>

It would render as:

<table>
<tr>
	<td class="a"><div class="b">
		Content here
		<table>
			<tr>
				<td class="a"><div class="b">
					More Content here
				</div></td>
			</tr>
		</table>
	</div></td>
</tr>
</table>

Now, I figure I can use RegExp to get the td's with the class name "a", but I have no idea how to dynamically create a div like that, particularly finding a closing td that belongs to an opening td with class "a". Any thoughts on how to accomplish this?

Thanks very much!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.