How to 'permanently' change color of an object at run time?


I’m currently using $(Bu1a).css("background","green") to change the color of a button, which works. I would like to have that color remain through a reload of the app (until the color is changed again using the same code, but to a different color). Currently, the color reverts to the original color when the app is reloaded and run.


Have you tried setting the color in the button properties in the IDE?

(This may or not work depending on the framework you are using).

Otherwise, put the code in a Sub Main() function, which gets called on startup.


In the ‘book like’ app i’m coding, there is one form that is the Table of Contents (TOC). Using a jQuery Collapsible control, all of the ‘pages’ (= Forms) titles are listed. Next to each title is a very small jQuery Button that can be touched to change it’s color in the button’s property (to be marked as a ‘favorite’) to green. I was looking for this green button (vs. white) to be available the next time the app is opened.

But that doesn’t happen, in that when reopened, the ‘favorite buttons’ are all back to white, even though the Background Color of the button was set to Green in the previous run of the app.

I think the way to do this is to set up an array, and when the button is clicked to green (a “favorite”) or clicked again back to white (not a “favorite”), the array entry for that button is updated… then when the app is reopened, all the ‘favorite’ buttons are updated (in an update routine in Sub Main()} to green or white depending upon the array content.


The array idea should work, but you will need to save the array so it can be reloaded when the app starts again. You can do using LocalStorage:

You will need to save the array as a string, since localStorage can only store strings.