I am using jquery to write true and false strings to data- html attributes. However when I write false to one of the attributes, and then check it it false, it returns true. I a
The simplest fix would be:
var is_activate = $(this).attr("data-is-panel-activated") !== "false";
or
var is_activate = $(this).attr("data-is-panel-activated") === "true";
depending on which semantics makes more sense for your code.
Boolean('false')
will return true
because the string 'false'
is truthy.
You could just run a check to see if the string equals 'false':
if ($(this).attr("data-is-panel-activated") === 'false') {
.....
}