javascript - How to Retrieve Cookie Value using Jquery JS Cookie -
i using jquery cookie plugin called js cookie , happens unable retrieve data or value in cookie. store value of cookie inputted on text box , retrieve in text field when page visited again.
$(document).ready(function() { var cookie_email = cookies.get('user_email'); $('#email_address').val(cookie_email); $('#test_button').click(function() { cookies.set('user_email', email_address, { expires: 365 }); }); });
your code doesn't work don't assign email_address variable anywhere. should change value use $('#email_address').val().
also note jsfiddle isn't setup correctly; url external cookie script goes github page. need use cdn link instead. try this:
var cookie_email = cookies.get('user_email'); $('#email_address').val(cookie_email); $('#test_button').click(function() { cookies.set('user_email', $('#email_address').val(), { expires: 365 }); });
Comments
Post a Comment