如何使用 Html 助手在 mvc 中显示密码隐藏字段

4 javascript c# asp.net-mvc jquery asp.net-mvc-4

@Html.Password("pasword", null, new { @class = "form-control frmField", placeholder = "Password" })
Run Code Online (Sandbox Code Playgroud)

我正在使用这个,我希望这里应该有一个按钮,我单击它,密码就会变得可见。我知道这将通过 jquery 或 Javascript 实现,但我无法在 mvc 中理解这一点。如何在 mvc 中应用该技术?

<input data-toggle="password" type="password"  data-placement="after" data-eye-class="glyphicon" data-eye-open-class="glyphicon glyphicon-eye-open" data-eye-close-class="glyphicon glyphicon-eye-close" data-eye-class-position="true" class="form-control pwd">
<input type="text" class="form-control" placeholder="password" style="display:none;" /> 
Run Code Online (Sandbox Code Playgroud)

我用过这个并且效果很好。在mvc中如何实现呢?

Far*_*rlo 5

密码类型更改为文本类型

$( ".btnShow" ).mousedown(function() {
  $(".pwd").attr("type","text");
});
$( ".btnShow" ).on("mouseleave",function() {
  $(".pwd").attr("type","password");
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input  type="password"  class="form-control pwd">
<input type="button" class="btnShow" value="show"/>
Run Code Online (Sandbox Code Playgroud)