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
https://forums.phpfreaks.com/topic/195768-dom-cleaning-need-a-function/
Share on other sites

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.