Avatar of sharingsunshine
Flag for United States of America

asked on 

In jQuery How Do You Do "If Test" On Cookie?

I am trying to have jquery write a cookie and test for its presence.  If if is present write a message in the order_comments box of Woo Commerce.  Here is an answer using jquery to write in the order_comments box.


Open in new window

Here is my present jquery code

<script type="text/javascript">

jQuery(function() {
		jQuery('#cook').click(function(e) {
		document.cookie = "wantmembership=1; path=/";
              jQuery(this).text("I Now Have A Membership!");


Open in new window

This creates the code.  I just need help knowing how to read the presence of the cookie and then write the message in the order_comments box.

Web Development* woo commercejQuery

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon