<html>
<head>
<style>
.tagging {
border: 1px solid black;
width: 20px;
height: 30px;
}
</style>
<script>
window.onload = function() {
var div = document.getElementsByTagName("div");
div[0].class = "tagging";
}
</script>
</head>
<body>
<div></div>
</body>
</html>
This is my code. I wonder why it doesn't work when I assign class attribute via javascript, but it works when I assign inline directly in html
<div class="tagging"></div>