简体   繁体   English

点击刷新后,保留链接更改后的值

[英]Retain changed value of a link when clicked after hitting refresh

How do you retain the changed name of a link after a reload or refresh of that page? 重新加载或刷新页面后,如何保留链接的更改名称?

$("a").click(function(){
    $(this).text("Hello");
});

At the moment, if I hit refresh, the link's name will be back to original. 此刻,如果我单击刷新,则链接的名称将恢复为原始名称。 In this case, I want to retain the value hello. 在这种情况下,我想保留值hello。

Help please. 请帮助。

. you can use jquery cookie pluing or you can use local storage plugin . 您可以使用jquery cookie插入 ,也可以使用本地存储插件 for better understand difference between local storage and cookie you can refer this link 为了更好地了解本地存储和cookie之间的区别,您可以参考此链接

$("a").click(function(){
  $(this).text("Hello");
  $.cookie('text', "Hello");
});

/// code to get value when page load ///代码以在页面加载时获取价值

 $(document).ready(function(){
   if($.cookie('text')){
     $("element").text($.cookie('text'));
   }
 })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM