Toggle Text

Example toggling text with JavaScript.

Preview

Code

<p id="toggleText">OFF</p>

<button onclick="
var el=document.getElementById('toggleText');
el.innerText = el.innerText === 'OFF' ? 'ON' : 'OFF';
">
Toggle
</button>

More HTML JavaScript Examples (7)