Attempting to retrieve the class of the parent node of a selected element using JavaScript, but encountering issues with the following code snippet. Any guidance on what needs to be corrected?
function getParentNodeClass() {
var parentNodeClass = this.parentNode.className;
return parentNodeClass;
}
Appreciate any help.