I have created a jsfiddle as I thought it would be the best way to show the problem. Basically, the script can change the button, but after the button changes, the header does not change. I am assuming it’s because the original button is been replaced:
Is it possible to somehow capture the original button so it can be used to remove replace the header even after the button has been removed?
Try changing your function like below,
DEMO