<!DOCTYPE html>
<html>
<body>
<div id="status" class="inactive">inactive</div>
<a href="#" id="tog">Toggle Me</a>
<script type='text/javascript'>
var btn = document.getElementById("tog");
btn.onclick = function() {
var statusDiv = document.getElementById('status');
var status = statusDiv.innerHTML;
if (status === 'inactive') {
statusDiv.className = 'active';
statusDiv.innerHTML = 'active';
} else {
statusDiv.className = 'inactive';
statusDiv.innerHTML = 'inactive';
}
return false;
}
</script>
</body>
</html>
The code above is rendered as follows: