How do you add/remove hidden in <p hidden> with JavaScript

It looks fine here. Try with this code if you wish.

index.html

<html>
<head>

</head>
<body>
      <p hidden>My Text</p>
</body>
</html>

script

let p = document.getElementsByTagName('p');
let myText;

for (i = 0; i < p.length; i++) {
  if (p[i].innerHTML == "My Text") {
    // console.log(myText, p[0].innerHTML);
    myText = p[i];
    break;
  }
}

myText.removeAttribute("hidden"); 

You can see in codePen https://codepen.io/anon/pen/qozVaq


Could you set an ID on the <p> tag and interact with it that way?

<p id="whatever" hidden>My Text</p>

And:

let p = document.getElementById('whatever');
p.removeAttribute("hidden");