Seeing the “ui-…” class names I suppose you are using jQuery, right? I’m gonna move the thread to the JS frameworks section.
Now, would you mind to share with us why you want to remove and change the items with JS rather than by just editing the HTML? In which context is this being used?
Donít click this link!