Click here to Skip to main content
11,647,644 members (65,911 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: jQuery
Hi, In our HTML on click function change the div bg color, but when page refresh change the colour. I don’t want to change the color after page refresh or reload.
.click {
<div class="click">click</div>
$(".click").click(function() {
Posted 1-Oct-12 21:58pm
Edited 1-Oct-12 22:06pm
Sandeep Mewara at 2-Oct-12 4:10am
On refresh/reload, background color set is retained?
Peeyush Pachaori at 2-Oct-12 4:19am
When you click on the button do you go on server?
subhakarb at 2-Oct-12 5:37am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If i understand u correct, then on page refresh you want to retain the bg color. Which will not be possible as when you refresh the page it loads again. To solve this problem you need to go to the server. On load function (client) you can write code to change the bg color based on some returned flag from server which you should set after you click on button.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

If you want to keep this change just between page refresh, you can use session cookie: just store in a cookie all altered styles and apply the on page load. But if you want to keep the between sessions on different clients, you need to store the changes on the server in some sort of personal preference or business data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 500
1 F-ES Sitecore 370
2 OriginalGriff 322
3 DamithSL 315
4 CPallini 240
0 OriginalGriff 1,342
1 994
2 DamithSL 971
3 Sergey Alexandrovich Kryukov 873
4 CPallini 795

Advertise | Privacy | Mobile
Web02 | 2.8.150804.3 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100