yes, you can do it by javascript. Let´s consider a simple example in which we call a javascript function by onclick event. In which we apply the css styles on a link.
<script type="text/javascript">
function change(){
document.getElementById("link").style.color="white";
document.getElementById("link").style.background="orange";
document.getElementById("link").style.padding="20px";
}
</script>
<a href="#" id="link" onclick="change()">Click here to apply css</a>
================================= Output =================================
Click here to apply css