classList
classList property remains consistent with the native.
Below is an example demonstrating how to use classList
:
<script src="https://cdn.jsdelivr.net/gh/kirakiray/ofa.js@4.5.26/dist/ofa.min.js"></script>
<style>
.t-red{
color: red;
font-size: 14px;
}
.t-blue{
color: blue;
font-weight:bold;
font-size:20px;
}
</style>
<div id="target" class="t-red">origin text</div>
<script>
setTimeout(()=> {
$("#target").classList.remove('t-red');
setTimeout(()=>{
$("#target").classList.add('t-blue');
},1000);
}, 1000);
</script>
The classList
property allows you to easily add, remove, and toggle class names to dynamically change an element's style. For more information on how to use it, please refer to classList.