Guest User

Guest User

  • Tech Writer
  • 31
  • 22.7k

Cookies in jQuery

May 11 2017 1:17 AM
  1. <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>  
  2.         <script src="js-cookie-master/src/js.cookie.js"></script>  
  3.         <script>  
  4.             $(function () {  
  5.                 $("button").click(function () {  
  6.                     alert("You clicked Submit button");  
  7.                     var uid = $("#username").val();  
  8.                     var pwd = $("#password").val();  
  9.                     $.cookie("username", uid);  
  10.                     $.cookie("password", pwd);  
  11.                     alert("username  =" + uid + "password = " + pwd);  
  12.                 });  
  13.             });  
  14.         </script>  
Here's my js to create cookie using jQuery. But it is not working. Why?

Answers (2)