So you have a document like this:
<!DOCTYPE html>
<html>
<head></head>
<body>
<textarea id="myText"></textarea>
</body>
</html>
In your Chrome console, you've done var view = document.getElementById('myText');
Now...
When you do view.setAttribute("hidden", true);
the document now looks like:
<!DOCTYPE html>
<html>
<head></head>
<body>
<textarea id="myText" hidden=true></textarea>
</body>
</html>
This will hide the element because there is a property hidden
that exists. Because hidden
is a property in HTML, its existence is all that is needed, the value is ignored.
When you do view.setAttribute("hidden", false);
the document now looks like:
<!DOCTYPE html>
<html>
<head></head>
<body>
<textarea id="myText" hidden=false></textarea>
</body>
</html>
But because hidden
is a property, the value is ignored and its presence is what sets it hidden.
When you do view.hidden=false;
the document now looks like:
<!DOCTYPE html>
<html>
<head></head>
<body>
<textarea id="myText"></textarea>
</body>
</html>
view.hidden=false
is equivalent to view.removeAttribute('hidden');