jquery - How to permanently change the color of some elements? -


i have php page on want user can change color of elements, , next time load page choices should loaded default.

i'm using jquery click() function change colors, , save changes on server side suppose best way using jquery/json, i'm totally new this.

should have separate json file color options stored? found many stories on web jquery/json, still need example how accomplish task. please useful link or code example.

 #div01 {         background:#008080;         color:#ffffff;     }   $('#btnblue').click(function () {     $('#div01').css('background', '#0000ff');     $('#div01').css('color', '#ffffff'); });  $('#btnred').click(function () {     $('#div01').css('background', '#ff0000');     $('#div01').css('color', '#0000ff'); }); 

if looking concrete example on how this, might trick. first, use javascript library: https://github.com/carhartl/jquery-cookie.

then, script:

var backgroundcolor = $.cookie('backgroundcolor'), color = $.cookie('color'); $('#div01').css('background', backgroundcolor); $('#div01').css('color', color);  $('#btnblue').click(function () {     $.cookie(backgroundcolor, '#0000ff');     $.cookie(color, '#ffffff');     $('#div01').css('background', backgroundcolor);     $('#div01').css('color', color); });  $('#btnred').click(function () {     $.cookie(backgroundcolor, '#ff0000');     $.cookie(color, '#0000ff');     $('#div01').css('background', backgroundcolor);     $('#div01').css('color', color); }); 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -