function name() {
const select = document.querySelector("#id");
select.classname = ("customclass")
}
I've written this code. But I'm unable to change the Classname.
function name() {
const select = document.querySelector("#id");
select.classname = ("customclass")
}
I've written this code. But I'm unable to change the Classname.
You need to change the
className
property:Another way would be adding it to the
classList
as suggested in the comments: