效果:
input内容不为空时,发送按钮颜色不透明,并且点击后可以执行跳转
内容为空时,发送按钮颜色透明,点击后无反应
主要代码如下:需要引用jquery
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
可以引用菜鸟教程编辑器里的jquery,也可以自己自行下载
<div class="msg-nav" >
<a href="MyMsg.aspx" class="back" >取消 </a>
<h3>写邮件</h3>
<a href="SendMsg.aspx" class="send not-active" id="send" onclick="return false">发送</a>
</div>
<div class="panel-body">
<ul >
<li><span class="textdes">收件人:</span>
<input name="info" type="text" id="accept" style="width:100%;" autofocus="autofocus"/>
</li>
</ul>
</div>
<style>
ul {
padding: 0px;
}
input{
margin-bottom:0 !important;
display:inline-block;
width:auto!important;
border:none!important;
}
li{
border:1px solid #ddd !important;
}
.textdes{
display:inline-block;
margin-left: 10px;
}
.back{
float:left;
margin-left:20px;
}
h3{
text-align:center;
display:inline-block;
position:absolute;
left:36%;
line-height:50px;
height:50px;
}
.msg-nav{
height:50px;
width:100%;
line-height:50px;
font-size:16px;
}
.send{
float:right;
margin-right:20px;
}
.not-active{
color:rgba(101, 206, 167, 0.38);
}
.not-active a:active,a:hover{
color:rgba(101, 206, 167, 0.38)!important;
}
</style>
<script>
$("#accept").bind("input propertychange", function () {
var accept = $(this).val();
if (accept !== null && accept !== "") {
$("#send").removeClass("not-active");
$("#send").removeAttr("onclick");
}
else {
$("#send").addClass("not-active");
$("#send").attr("onclick", "return false;");
}
});
</script>