【发布时间】:2020-01-06 13:07:54
【问题描述】:
在这个问题中有这个问题的以下答案,但我给出了这个问题的最佳答案。
function myFunction() {
var data = document.getElementById("myInput");
if (data.type === "password") {
data.type = "text";
} else {
data.type = "password";
}
}
<div class="form-group col-md-6">
<label class="control-label">Password</label>
<input type="Password" name="password password1" id="myInput" class="form-control eye" value="{{old('password')}}">
<i class="fa fa-eye" aria-hidden="true" onclick="myFunction()"> Show Hide</i> {!! $errors->first('password', '<p class="text-warning errorBag">:message</p>') !!}
</div>
请分享我的答案
【问题讨论】:
-
您有什么问题吗?
-
还有一件事是在函数外声明变量,因为每次调用函数时js访问dom树,效率有点低
标签: javascript html passwords show-hide input-field