2016-08-12 1 views
0

私はサインアップフォームを作成するために基礎レールを使用しています。 DIV内部:text_field_tag(foundation-rails)内のアイコン

<%= text_field_tag "password", "", placeholder: password", class:"password", required: true, type: "password" %> 
<small class="error">Invalid</small> 

私はパスワードが表示されるべきのクリックで、(右側)「ショー・パスワード」またはこのフィールド内のアイコンを持っていると思います。

font_field_tagの中にフォントの素晴らしいアイコンを配置する方法???

答えて

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; 
} 

を追加します。あなたの答えのための

<script> 
    $('.password').find('.fa-eye').click(function(){ 
     $('#password').prop("type", "text"); 
    }) 
</script> 
+0

おかげjsのスクリプトを追加します。それは素晴らしい仕事をした。 '$( '#password')を除いて。type = 'text';'。代わりに '$("#password ")を使用しましたprop(" type "、" text ");' – smanvi12

+0

ありがとうございました。私は答えを編集しました –

関連する問題