The_Hobyte
The_Hobyte

Reputation: 21

Remember changes made in css

I have a question about jquery, I want the user to be able to change the color of his/her profile. How could I manage to let the website "remember" that the changes were made?

$(document).ready(function() {
    $('#color2').click(function() {
        $('#color').css("border-color", "#3498db").css("color", "#3498db");
        $('.navbar-default').css("background-color", "#3498db");
    });
});

this is what I have to make the change

Upvotes: 2

Views: 163

Answers (2)

Konrad Viltersten
Konrad Viltersten

Reputation: 39078

If it's a simple application, you might want to use the local storage of the browser.

localStorage.setItem('color', '#123456');
localStorage.getItem('color');
localStorage.clear();

Note that it's not bound to the users' profiles but scoped to the browser in use. If they go with another browser or use a different machine, the setting isn't known, which can create a weird issue when they jump between settings without understanding why.

In such case, you're better off seding the value picked to the server and storying it there. That requires you to managed it in the server-end code, which might be pulling a nuke to kill a fly.

Upvotes: 1

netto
netto

Reputation: 135

This could be done via cookie or save it on your database using php not jquery, because jquery is used for user interaction or interface but you can use it to retrieve data using ajax.

Upvotes: 0

Related Questions