First of all
that is not valid HTML. Read up on custom data attributes or use the following instead:
Since "data-value" is an attribute, you have to use the getAttribute function to retrieve its value.
var cookieValue = document.getElementById("demo").getAttribute("data-value");