JavaScript/attribute

来自康健生活

引言

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