Can you store intermediate values in a session using javascript? What are the disadvantages of this method, if it exists?
For example, I need to store the value on the basis of which the script behavior on the page will be set.
In this example, it is currentAtomicNumber , which compares the value obtained from the attribute, below is a piece of code:
function openElementDetailBlock(event) { var target = event.target; var currentAtomicNumber; while (target != this) { if (target.hasAttribute('data-number')) { var atomicNumber = target.getAttribute('data-number'); if (atomicNumber != currentAtomicNumber) { elementDetailBlock.classList.toggle('element-detail_opened'); setTimeout(elementDetailBlock.classList.add('element-detail_opened'), 1000); currentAtomicNumber = atomicNumber; } } target = target.parentNode; } } One solution I see is the use of a hidden field, an attribute that changes to the resulting value, but this solution does not seem to me to be too correct.
Tell me, what can be the ways of saving the value if JS is not suitable for this task?