0

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.

Help please.

1 Answers1

-1

. you can use jquery cookie pluing or you can use local storage plugin . for better understand difference between local storage and cookie you can refer this link

$("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'));
   }
 })
Community
  • 1
  • 1
Nishit Maheta
  • 6,021
  • 3
  • 17
  • 32