禁用和启用按钮
答
您可以使用下面的代码,将工作,当页面加载Button1的将被禁用,BUTTON2将被启用和BUTTON2的Button1点击将被启用也就是说
JS:
$("#button1").prop("disabled", true);
function buttonClick(){
$("#button1").prop("disabled", false);
}
在HTML:
<input type="button" id="button2" onclick="buttonClick()">
答
<html>
<!-- Include jQuery library -->
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<!-- Your css -->
<style>
#button1, #button2 {
width: 70px;
height: 30px;
background-color: #fff;
color: #000;
border: 1px solid black;
cursor: pointer;
}
#button1.disabled {
cursor: not-allowed;
background-color: #e6e6e6;
color: #808080;
}
</style>
<!-- jQuery -->
<script>
$(document).ready(function(){
$('#button2').on('click', function(){
$('#button1').removeClass('disabled');
$('#button1').on('click', function(){
// Your button 1 function
});
});
});
</script>
<!-- Content -->
<body>
<div id="button1" class="disabled">Button 1</div>
<div id="button2">Button 2</div>
</body>
</html>
希望我回答你的问题。
答
将下面的css添加到按钮中: pointer-events:none;
如果u要启用THW按钮,添加下面的CSS:
指针的事件:defau
还不如在这里粘贴代码,以便我们能够帮助您更好地 –
欢迎StackOverflow上。请注意,这不是一个免费的代码写入服务,但我们渴望帮助其他程序员(和有志之士)编写他们自己的代码。请阅读[如何提出问题](http://stackoverflow.com/help/how-to-ask)上的帮助主题。之后,请用您迄今编写的代码更新您的问题,以完成您希望实现的任务。 –