首页题目详情

在JavaScript中,哪条语句可以移除一个元素的所有类名?

题目配图
A.element.classList.remove()
B.element.classList.clear()
C.element.className = ''
D.element.classList.delete()

优质解答

答案

C

解析

在JavaScript中,直接将className属性设为空字符串可以移除所有类名。classList对象没有clear()方法,而delete()方法已被弃用。

查看答案和解析

支付 ¥0.1 即可查看此题答案和详细解析

低至 ¥0.1 起

Web程序设计单选题中等AI生成