JavaScript/attribute

来自康健生活
Kangkk​(留言 | 贡献)2021年9月12日 (日) 04:16的版本 (→class)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

引言

class

classList

contains ele.classList.contains('checked') 含有
remove ele.classList.remove('checked') 示例
add ele.classList.add('checked') 示例
Warning: IE 10 以下不兼容?(未确定)

getAttribute

ele.getAttribute('class').indexOf('checked') > -1
//
node.className.indexOf('checked') > -1