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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.