避免在刷新/重新加载时改变颜色 [英] Avoid change of color on refresh/reload

查看:62
本文介绍了避免在刷新/重新加载时改变颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我们的HTML单击功能中,更改div bg颜色,但是在页面刷新时更改颜色.我不想在刷新或重新加载页面后更改颜色.

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.

<style>
.click {
width:100px;
height:100px;
background:green;
}
</style>
<div class="click">click</div>





$(".click").click(function() {
        $(this).css("background","red");
}

推荐答案

(" ).click(
(".click").click(function() {


(" " ); }
(this).css("background","red"); }


如果我理解正确,那么在页面刷新时您要保留bg颜色.当您刷新页面时,将无法再次加载.要解决此问题,您需要转到服务器.在加载功能(客户端)上,您可以编写代码以根据服务器返回的某些标志更改bg颜色,该标志应在单击按钮后设置.
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.


这篇关于避免在刷新/重新加载时改变颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆