Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Live https://codepen.io/Sohail05/pen/yOpeBm
- //HTML
- <div class="ic-single-input">
- <input id="password-field" type="password" placeholder="password">
- <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password"></span>
- </div>
- // css
- .ic-single-input {
- position: relative;
- }
- .ic-single-input .toggle-password {
- position: absolute;
- right: 10px;
- top: 17px;
- font-size: 20px;
- }
- //JS
- $(".toggle-password").click(function() {
- $(this).toggleClass("fa-eye fa-eye-slash");
- var input = $($(this).attr("toggle"));
- if (input.attr("type") == "password") {
- input.attr("type", "text");
- } else {
- input.attr("type", "password");
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement