html - 单击另一个按钮后如何设置按钮样式?
问题描述
我试图在单击按钮 1 后将按钮 2 更改为手指指针,所以我想知道是否有办法做到这一点,如果有请告诉我我要写什么代码注意:按钮 1 已经是我想要按钮 2 的手指指针单击按钮 1 后成为手指指针这是我的代码:
<input type="button" id="button1" type="submit" style="cursor: pointer; background-color:black;height: 45px; width: 150px; color:red;border-radius:10px;"value="first button" onclick="enableButton2()" />
<input type="button" id="button2" style="background-color:yellow; height: 45px;width: 225px;color:red;border-radius:10px;"value="second button" disabled />
解决方案
用它 :
<script>
function enableButton2(){
var btn2 = document.getElementById('button2');
btn2.setAttribute('disabled', false)
btn2.style.cursor = 'pointer'
}
</script>
<input type="button" id="button1" type="submit" style="cursor: pointer; background-color:black;height: 45px; width: 150px; color:red;border-radius:10px;" value="first button" onclick="enableButton2()" />
<input type="button" id="button2" style="background-color:yellow; height: 45px;width: 225px;color:red;border-radius:10px;" value="second button" disabled="true" />
推荐阅读
- reactjs - 路由参数链接没有重定向
- sql - SQL - 比较表的特定要求
- python-3.x - 未绘制箭头
- javascript - ES6 变量作用域:无法访问函数内的值
- django - 如何同时运行 Daphne 和 Gunicorn?
- mysql - SQLite Group 通过给出重复项
- .net - 尝试在 ubuntu 18.04 上运行 Numpy.Net 时出现“未定义符号:_PyObject_NextNotImplemented”错误
- javascript - 我无法在 Javascript 中读取 JSON 文件并返回对象
- node.js - 如何使用 multipart/form-data 在标头中传递授权令牌
- json - 将字典转换为 JSON 特定格式