This version works:
let element = document.getElementById("lcSitemapCategory");
element.addEventListener("click", function() {
var hiddenField = $('#lcSitemapCategoryHidden'),
val = hiddenField.val();
hiddenField.val(val === "true" ? "false" : "true");
$('#lcSitemapCategory').val(val === "true" ? "false" : "true")
});
6
solved How to create a Javascript click event without jQuery? [closed]