<!DOCTYPE html>
<html>
<head>
<title>How to get class name by ID javascript</title>
</head>
<body>
<ul>
<li id="myId" class="myClass">Item one</li>
</ul>
<button onclick="myFunction()">Click me</button>
<script>
function myFunction() {
var li = document.getElementById('myId');
alert(li.className);
}
</script>
</body>
</html>