JavaScript/attribute:修订间差异
来自康健生活
创建页面,内容为“== 引言 == == class == === classList === {| class="wikitable" |- | contains || <code>ele.classList.contains('checked')</code> || 含有 |- | remove || <code>ele.cl…” |
|||
| 第11行: | 第11行: | ||
|} | |} | ||
{{Warning|IE 10 以下不兼容{{Qm}}}} | {{Warning|IE 10 以下不兼容{{Qm}}}} | ||
=== getAttribute === | |||
<syntaxhighlight lang="javascript"> | |||
ele.getAttribute('class').indexOf('checked') > -1 | |||
// | |||
node.className.indexOf('checked') > -1</syntaxhighlight> | |||
2021年9月12日 (日) 04:16的最新版本
引言
class
classList
| contains | ele.classList.contains('checked') |
含有 |
| remove | ele.classList.remove('checked') |
示例 |
| add | ele.classList.add('checked') |
示例 |
getAttribute
ele.getAttribute('class').indexOf('checked') > -1
//
node.className.indexOf('checked') > -1
No categories