JSFiddle - React, Tailwind, and code Playground
by DannyEnglander
HTML
<script src="http://dev.bridgebase.com/barmar_test/jquery.cookie.js"></script>
<div class="form-checkbox checkbox-input">
<p>
Hi
</p>
</div>
<fieldset class="toggle_container" id="webform-component-donor-information--spouse-partner">
<div class="block">
Hello
</div>
</fieldset>
JavaScript
$(document).ready(function() {
// Set the cookie with a name.
console.log("Initial cookie: "+($.cookie('showTop11')));
// initially hide the spouse fieldset.
$("#webform-component-donor-information--spouse-partner").toggle($.cookie('showTop11') === 'collapsed');
// On checkbox click:
$(".form-checkbox.checkbox-input").click(function() {
$(this).toggleClass("active").next('#webform-component-donor-information--spouse-partner').toggle();
var new_value = $("#webform-component-donor-information--spouse-partner").is(":visible") ? 'collapsed' : 'expanded';
console.log("New value: "+new_value);
$.cookie('showTop11', new_value);
});
});