web蓝桥杯真题:冰墩墩心情刻度尺

代码:

// TODO: 待补充代码
BingDunDun.className='BingDunDun not-satisfied'
range.onchange = (e) => {
  let value = Number(e.target.value); // value 进度条的值
  // TODO: 待补充代码
  if(value == 25) {
    BingDunDun.className='BingDunDun a-little-unsatisfied'
  } else if(value == 50) {
    BingDunDun.className='BingDunDun ordinary'
  } else if(value == 75) {
    BingDunDun.className='BingDunDun satisfied'
  } else if(value == 100) {
    BingDunDun.className='BingDunDun great'
  } else {
    BingDunDun.className='BingDunDun not-satisfied'
  }
};

考察:

元素添加类名:element.className='class1 class2'   

此外,

行内样式操作:element.style.width = '250px'

给元素添加样式:element.classList.add(newClassName)      

给元素移除样式:element.classList.remove(oldClassName)

className和classList.add的区别:

前者是直接替换原来的类名,后者是在原类名基础上再加一个类名

相关推荐

  1. web心情刻度尺

    2024-03-11 03:16:05       53 阅读
  2. web:展开你的扇子

    2024-03-11 03:16:05       47 阅读
  3. web:卡片话标签页

    2024-03-11 03:16:05       38 阅读
  4. web:分阵营,比高低

    2024-03-11 03:16:05       34 阅读
  5. web:搜一搜呀

    2024-03-11 03:16:05       40 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-11 03:16:05       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-11 03:16:05       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-11 03:16:05       82 阅读
  4. Python语言-面向对象

    2024-03-11 03:16:05       91 阅读

热门阅读

  1. 【c++】模板的使用

    2024-03-11 03:16:05       47 阅读
  2. 设计模式 | 单例模式 | 懒汉&饿汉

    2024-03-11 03:16:05       43 阅读
  3. python的类修饰器

    2024-03-11 03:16:05       50 阅读
  4. LeetCode1547. Minimum Cost to Cut a Stick——区间dp

    2024-03-11 03:16:05       51 阅读
  5. 前端缓存使用规范

    2024-03-11 03:16:05       34 阅读
  6. 深入了解 Jetpack Compose 中的 Modifier

    2024-03-11 03:16:05       47 阅读
  7. 基于单片机的四路抢答器的设计

    2024-03-11 03:16:05       46 阅读