<p>How can I change the class of an HTML element in response to an <code>onclick</code> or any other events using JavaScript?</p>

This is easiest with a library like jQuery:
```
```
<input type="button" onClick="javascript:test_byid();" value="id='second'" />

<script>
function test_byid()
{
    $("#second").toggleClass("highlight");
}
</script>
```
```