我正在使用foundation-rails创建一个注册表单。在div里面:
<%= text_field_tag "password", "", placeholder: password", class:"password", required: true, type: "password" %>
<small class="error">Invalid</small>
我希望在此字段(右侧)中显示“显示密码”或图标,点击该密码应显示密码。
如何在text_field_tag中放置一个字体真棒图标
答案 0 :(得分:1)
<div class="password">
<span class="fa fa-eye"></span>
<%= text_field_tag "password", "", placeholder: password", class:"password", required: true, type: "password" %>
</div>
添加到css
.password {
position: relative;
}
.password input { text-indent: 32px;}
.password .fa-eye {
position: absolute;
top: 10px;
left: 10px;
cursor: pointer;
}
添加js脚本
<script>
$('.password').find('.fa-eye').click(function(){
$('#password').prop("type", "text");
})
</script>