K
K
kimqar2020-05-08 10:58:08
JavaScript
kimqar, 2020-05-08 10:58:08

How to delete cookies on second click on the cookie button?

There is a button, by pressing which the value is written to the cookie. How can I make this value disappear or overwrite on another click? In short, the functionality is similar to ToggleClass
5eb510d881961295887891.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Ivanov, 2020-05-08
@maksim_fix

$('#button').click(function() {
    if(!$.cookie('but')){
        $.cookie('but', true);
    } else {
        $.removeCookie('but');
    }
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question