function getCookie(name) {
let matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
let statePopup = getCookie('statePopup');
if (statePopup) {
$('.popup').css({
'display': 'none'
});
}
$('button').on('click', function() {
$('.popup').css({
'display': 'none'
});
document.cookie = `statePopup=${1}; path=/; max-age=2592000`;
});
.popup {
background-color: blue;
}
p {
color: red;
}
<div class="popup">
<p>test popup</p>
<button>согласиться с куками</button>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. At minima rem vero aliquam autem cum recusandae perferendis, voluptates voluptatum. Enim vitae harum voluptas fuga quibusdam neque veritatis omnis, sapiente unde.</p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>