当前位置: 首页 > news >正文

JS06-class对象

class对象

className

修改样式

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>div {width: 200px;height: 200px;background-color: aqua;}.action {width: 300px;height: 300px;background-color: pnik;margin-left: 100px;}</style>
</head>
<body><div></div><script>let box = document.querySelector('div')box.className = 'action'</script>
</body>
</html>

classList

修改样式

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>div {width: 200px;height: 200px;background-color: aqua;}.action {width: 300px;height: 300px;background-color: pnik;margin-left: 100px;}</style>
</head>
<body><div class="one"></div><script>let box = document.querySelector('div')// add 追加box.classList.add('action')// remove 移除box.classList.remove('one')// 切换类box.classList.toggle('one')</script>
</body>
</html>

修改表单属性

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title>
</head>
<body><input type="text" name="" id="" value="请输入"><button disabled>按钮</button><input type="checkbox" name="" id="" class="agree"><script>let input = document.querySelector('input')input.value = '小米'input.type = 'password'let btn =document.querySelector('button')btn.disabled = truelet checkbox = document.querySelector('.agree')checkbox.checked = true</script>
</body>
</html>

间歇函数(定时器)

        setInterval(function(){console.log('color');},1000)function show (){console.log('Zero')}// 开启定时器let timer = setInterval(show,1000)// 清除定时器clearInterval(timer)
http://www.lryc.cn/news/319944.html

相关文章:

  • 深度学习1650ti在win10安装pytorch复盘
  • Node.js与webpack(三)
  • 测试覆盖率那些事
  • Etcd 介绍与使用(入门篇)
  • Docker 安装 LogStash
  • Selenium笔记
  • ChatGPT :确定性AI源自于确定性数据
  • linux驱动开发面试题
  • 【AI】Ubuntu系统深度学习框架的神经网络图绘制
  • AI推介-大语言模型LLMs论文速览(arXiv方向):2024.03.05-2024.03.10—(2)
  • AI解答——DNS、DHCP、SNMP、TFTP、IKE、RIP协议
  • 【TypeScript系列】声明合并
  • zookeeper基础学习之六: zookeeper java客户端curator
  • MySQL数据库操作学习(2)表查询
  • Java学习
  • C#八皇后算法:回溯法 vs 列优先法 vs 行优先法 vs 对角线优先法
  • springboot整合swagger,postman,接口规范
  • 029—pandas 遍历行非向量化修改数据
  • 相机安装位置固定后开始调试设备供电公司推荐使用方法
  • AI视频批量混剪系统|罐头鱼AI视频矩阵获客
  • 线程池学习-了解,自定义线程池
  • CentOS7.9 安装SIPp3.6
  • Java零基础入门-LinkedHashMap集合
  • LRC转SRT
  • mybatis源码阅读系列(二)
  • 【Web开发】CSS教学(超详细,满满的干货)
  • 系列学习前端之第 5 章:学习 ES6 ~ ES11
  • Linux学习(4)——使用编辑器
  • 简单函数_短信计费
  • centos命令history设置记录10000行