jquery - 在同一个视图上有两个表单,为什么我只能在第二个表单中输入文本?
问题描述
我有一个视图,它有两种形式,奇怪的是我只能在第二种形式的文本框中输入文本。
首先,div 的 ManualLogin 和 ForgotLogin 都将其不透明度设置为 0,这是在代码尝试自动验证用户身份时,ManualLogin div 的不透明度设置为 1。单击“忘记凭据”会切换 div 的不透明度ManualLogin 为 0,ForgotLogin 为 1。
就目前而言,用户名和密码文本框不能输入文本,可以输入电子邮件文本框。
如果我将 ForgotLogin div 交换到 ManualLogin div 之前,我可以在用户名和密码字段中输入文本,但不能在电子邮件字段中输入文本。
如果我将其设置为同时显示两个表单,则可以在所有框中输入文本。
是什么原因造成的,我该如何解决?
<div id="MainLoginDiv">
<div id="LoginHeaderDiv" class="text-center">
<h3 id="LoginHeader" class="page-header" style="color:white;"> </h3>
</div>
<div id="ManualLogin" class="box" style="border: none;">
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-group">
<label class="control-label" style="color:white;">Username</label>
@Html.TextBox("username", null, new { id = "username", @class = "form-control", @Value="us" })
</div>
<div class="form-group">
<label class="control-label" style="color:white;">Password</label>
@Html.TextBox("password", null, new { id = "password", @class = "form-control", @Value = "pwd" })
</div>
<div class="text-center" style="margin-top:40px;">
<input type="button" id="ManualLoginBtn" value="Sign in" class="btn btn-primary" />
<br />
<input type="button" id="AutoLoginBtn" value="Auto Authenticate" class="btn btn-default" />
<input type="button" id="ForgotLoginBtn" value="Forgot Credentials" class="btn btn-default" />
</div>
}
</div>
<div id="ForgotLogin" class="box" style="border: none;">
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-group">
<label class="control-label" style="color:white;">Email</label>
@Html.TextBox("email", null, new { id = "email", @class = "form-control", @Value = "jhjhblah" })
</div>
<div class="text-center" style="margin-top:40px;">
<input type="button" id="BackToLoginBtn" value="Back" class="btn btn-default" />
<input type="button" id="ForgotSubmitBtn" value="Submit" class="btn btn-primary" />
</div>
}
</div>
要切换这些 div,我只是使用 jquery 来更改 css 不透明度,例如
$("#ManualLogin").css("opacity", "0");
$("#ForgotLogin").css("opacity", "1");
解决方案
尝试使用
$("#ManualLogin").css("display", "none");
$("#ForgotLogin").css("display", "block");
推荐阅读
- hash - 如何在 ETH_RSS_VXLAN 或 ETH_RSS_GENEVE 上为 DPDK 应用程序启用 RSS?
- docker - 两个容器一个组成文件网络不工作
- php - 如果主机通过 htaccess 匹配到某些主机列表,则在内部重定向
- kubernetes - Kubernetes 将 jar 复制到 pod 中并重新启动
- sharepoint - 从多个 Sharepoint 中提取数据到 SQL 数据库
- scala - 是否有任何类型安全的 API 用于结构化流式窗口操作
- node.js - 如何在同一个 API 调用中指定拒绝未授权和代理信息?
- android - Android 下载管理器无法在可移动存储中运行
- python - 如何在一个图中绘制多个参数图?
- c# - 将一个列表框中的所有项目添加和删除到另一个列表框