Skip to content

Instantly share code, notes, and snippets.

@omnisonic
Created January 22, 2020 01:02
Show Gist options
  • Save omnisonic/9b80bbeb8329b20041947e6bdf3f1b9a to your computer and use it in GitHub Desktop.
Save omnisonic/9b80bbeb8329b20041947e6bdf3f1b9a to your computer and use it in GitHub Desktop.
ZEYVKjL
<!DOCTYPE html>
<html>
<body>
<p>An unordered list:</p>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<p>Click the button to display text from the document.</p>
<button onclick="showOnclick()">Try it</button>
<p id="demo"></p>
</body>
</html>
var para = document.getElementsByTagName("p");
i = 0;
function showOnclick() {
document.getElementById("demo").innerHTML = para[1].innerHTML.charAt(i);
i += 1;
console.log(para[1].innerHTML.charAt(i));
}
//for (var i = 0; i < para[1].innerHTML.length; i++)
// showOnclick(para[1].innerHTML.charAt(i));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment