Jump to content

DOM cleaning, need a function


optikalefx

Recommended Posts

this one is tricky.  I am doing a lot DOM manipulation with js and jquery.  After some time i get a lot of these

 

Great blog
<span style="font-weight: bold;"> 
post
<span style="font-weight: bold;"> 
	from the Ba
</span>
ltimo
</span>
team

 

Think anyone can come up with a function that starts at the body, and traverses the entire DOM and cleans this kind of stuff up? Its ok if it takes a while.

 

the above code should be cleaned to this

<span style="font-weight:bold">Great Blog Post from the Baltimore team</span>

 

of course you have to worry about not combing elements if they don't have the same style, and you can't just compare siblings, because sometimes children need to combined up to their parents.

 

so 2 sub functions to make this happen would be like

 

combineParentWithChild

 

and then CombineSiblings

 

i think.

 

thanks!

 

 

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.