I want to change the attribute of a class on which all element that use the class for the rest of the web application life (from start of use until the user exits the web ap
I had this same goal on mind, I use hashes + ajax to navigation recordsets and I wanted viewing preferences of recordsets to be saved easily. (I wanted links to removable if the user preferred to navigate the records with links, or invisible if they chose).
DaveInMaine's answer is great but I worry a bit about backwards compatibility so I strove for a simple solution.
By naming my table, a static element, recordTable, giving it a class of LinksOn and I can use style selectors like #recordTable.LinksOn a and #recordTable.LinksOff a with display set to none, and use a simple javascript like
javascript:$('#recordTable').toggleClass('LinksOn').toggleClass('LinksOff');
By storing the last class in a variable in a cookie, server-side session via ajax, or localStorage, I can save it between sessions if I like.
I could do this all with a single class (#recordtable and #recordtable.on, rather than on and off), but I chose to store it this way.