Author Topic: DOM cleaning, need a function  (Read 323 times)

0 Members and 1 Guest are viewing this topic.

Offline optikalefxTopic starter

  • Enthusiast
  • Posts: 363
  • Gender: Male
  • youtube.com/optikalefxx
    • View Profile
    • Square Bracket
DOM cleaning, need a function
« on: March 19, 2010, 01:30:56 AM »
this one is tricky.  I am doing a lot DOM manipulation with js and jquery.  After some time i get a lot of these

Code: [Select]
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
Code: [Select]
<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!

echo "Hello Me"