lundi 27 juillet 2015

Change CSS depending on whether a checkbox that is stored in local storage is active/checked

I would like to be able to check if a checkbox has been checked against a value in local storage. If it is checked I would like to apply a background colour to a part of the page.

Page to apply CSS

My local storage data looks like the following:

Local storage data

If the completion checkbox is active I would like to apply a green background and if not an orange background.

I have the following code so far but am new to JS and so it needs a lot of work:

function highlightComplete() {
        if (DevPlan.completion == 'true') {
                info-row.addClass('background-green');
            } else if (DevPlan.completion == 'false') {
                info-row.addClass('background-orange');
            } 
    }

Any help would be greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire