按钮.disabled
获取按钮的禁用状态
按钮.disabled = true 或者false
设置按钮的禁用状态
示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button>点击</button>
<script>
// 1. 获取
const button = document.querySelector('button')
// 打印按钮的禁用状态
console.log(button.disabled)
// 禁用按钮
button.disabled = true
console.log(button.disabled)
</script>
</body>
</html>
控制台输出:
展示效果: