📅  最后修改于: 2022-03-11 15:03:23.493000             🧑  作者: Mango
const mssg = document.querySelector('p');//get the class of the p tag
console.log(mssg.getAttribute('class'));//the class is currently 'error'
mssg.setAttribute('class', 'success');//now the p tag's class is changed to 'success'
console.log(mssg.getAttribute('class'));//the new class of the p tag is 'success'